├── .gitignore
├── .travis.yml
├── CHANGES
├── LICENSE
├── README.md
├── bin
└── yae
├── build
├── build.bat
├── core
├── VERSION
├── android
│ ├── build.gradle
│ └── res
│ │ └── values
│ │ └── styles.xml
├── build.gradle
├── debug.keystore
├── desktop
│ └── build.gradle
├── gradle.properties
├── gradlew
├── gradlew.bat
├── gradlew.jar
├── gradlew.properties
├── ios
│ ├── Info.plist.xml
│ ├── build.gradle
│ ├── data
│ │ ├── Default-414w-736h@3x.png
│ │ ├── Default-568h@2x.png
│ │ ├── Default.png
│ │ ├── Default@2x.png
│ │ ├── Default@2x~ipad.png
│ │ └── Default~ipad.png
│ └── robovm.xml
├── libs
│ ├── bcel.jar
│ ├── luaj.jar
│ └── snakeyaml.jar
├── platforms
│ ├── android
│ │ ├── AndroidLauncher.java
│ │ └── AndroidManifest.xml
│ ├── desktop
│ │ └── DesktopLauncher.java
│ └── ios
│ │ ├── IOSLauncher.java
│ │ └── robovm.properties
├── settings.gradle
└── shared
│ ├── build.gradle
│ ├── precompile
│ ├── precompile.bat
│ └── src
│ └── yae
│ ├── Callbacks.java
│ ├── Helpers.java
│ ├── LoadingScreen.java
│ └── YaeVM.java
├── doc
├── config.ld
└── ldoc.css
├── res
├── .gitignore
├── font.ttf
├── icon.png
└── main.moon
├── src
├── yae.moon
└── yae
│ ├── accelerometer.moon
│ ├── audio.moon
│ ├── compass.moon
│ ├── console.moon
│ ├── constants
│ ├── aligns.moon
│ ├── blendmodes.moon
│ ├── buttons.moon
│ ├── filters.moon
│ ├── formats.moon
│ ├── init.moon
│ ├── keys.moon
│ ├── shapetypes.moon
│ └── wraps.moon
│ ├── filesystem.moon
│ ├── graphics.moon
│ ├── java.moon
│ ├── keyboard.moon
│ ├── mouse.moon
│ ├── objects
│ ├── File.moon
│ ├── Font.moon
│ ├── Image.moon
│ ├── Quad.moon
│ └── Source.moon
│ ├── system.moon
│ ├── timer.moon
│ ├── touch.moon
│ └── window.moon
└── yae-dev-1.rockspec
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Lua
2 | *.def
3 | *.rock
4 | *.rc
5 | *.res
6 |
7 | ## LDoc
8 | doc/build/
9 |
10 | ## Java
11 | build/
12 | .gradle/
13 | local.properties
14 | .gradle-app.setting
15 | *.class
16 |
17 | ## OS Specific
18 | .DS_Store
19 | Thumbs.db
20 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 |
3 | android:
4 | components:
5 | - build-tools-20.0.0
6 | - android-20
7 |
8 | install:
9 | - sudo apt-get install luarocks
10 | - sudo luarocks make
11 |
12 | jdk: oraclejdk7
13 |
14 | script:
15 | - yae new "My Game"
16 | - yae build desktop
17 | - yae build android
18 |
--------------------------------------------------------------------------------
/CHANGES:
--------------------------------------------------------------------------------
1 | [0.7.0]
2 | - changed API to be mostly LÖVE compatible
3 | - removed bg.png
4 | - removed bar.png
5 | - removed logo.png
6 | - added AOT Lua and MoonScript compiler
7 | - changed loading screen a bit
8 | - drastically improved view transformations performance
9 | - drastically reduced build times
10 | - new default font (Roboto Light)
11 | - new icon (Moon)
12 | - changed default textures filter to "Linear" (was "Nearest" before)
13 | - to simplify engine removed option to change native iOS splash before actual NON splash
14 | - reduced log output to console
15 | - fixed small bug what caused that engine was ignoring directories with name "non"
16 | - fixed require function
17 | - now "require" function works same as LOVE require function
18 | - fixed engine not be able to load "config.yml" when running from compiled JAR
19 | - moved desktop.display to window in config.yml
20 | - fixed %PACKAGE_DIR% not updating for iOS builds
21 | - added support for changing Android and iOS display orientation ("landscape" or "portrait")
22 | - added support for "sensor" Android and iOS display orientation and made it default
23 | - installation from LuaRocks is now fully automated
24 | - fixed non.mouse.isDown (by accident I mapped there keycodes rather than buttoncodes
25 | - documented entire source code and added LDoc support
26 | - added non.config module
27 | - rewrote entire command-line launcher in Lua
28 | - added support for LuaRocks
29 | - changed "init" cli command to "new"
30 | - added checks for cli task if project is not present or already exists
31 | - now console output is sexy and colorful
32 | - renamed "config.yml" to "project.yml"
33 | - renamed non.config to non.project
34 | - renamed engine to "Yae"
35 | - added support for building native Windows, Linux and Mac OS X executables
36 | - updated LibGDX, RoboVM, Android and YAML runtime to latest versions
37 | - simplified loading screen, now it displays the icon in center and text under it
38 |
39 | [0.6.4]
40 | - fixed documentation for methods that returns multiple values
41 | - fixed Java to Lua object binding
42 | - added non.java module
43 | - added support for including dependencies for repositories from mvnrepository.com
44 | - added -d switch to cli for debug log output
45 | - fixed out of memory error on iOS builds
46 |
47 | [0.6.3]
48 | - added documentation for MoonScript
49 | - optimized rendering of loading screen
50 | - removed automatic resizing of screen canvas (now it is resized only at game start)
51 | - removed unused Java code
52 | - now launcher loads version directly from VERSION file
53 | - added non.system.getSize(), non.system.getWidth() and non.system.getHeight() to get device screen size
54 | - added non.graphics.setSize(width, height) to change current screen size (usefull for screen cropping)
55 | - changed non.graphics.getSize(), non.graphics.getWidth() and non.graphics.getHeight() to return current screen size
56 |
57 | [0.6.2]
58 | - updated LibGDX backend to v1.5.5
59 | - updated RoboVM backend to v1.0.0
60 | - updated Gradle Android plugin to v1.1.3
61 | - updated Gradle Android SDK manager plugin to v0.12.0
62 | - updated and optimized Lua backend
63 | - added proper stacktrace to Lua backend
64 | - fully documented entire API
65 | - fixed defaults for "non start" and "non build"
66 | - fixed android builds
67 | - added non.system module and moved utility methods from non to it
68 | - added non.compass module
69 | - added non.files.copy(from, to, type1, type2)
70 | - added non.files.move(from, to, type1, type2)
71 | - added non.files.rename(from, to, type)
72 | - added non.files.parent(file, type)
73 | - added non.files.child(dir, child, type)
74 | - added non.mouse.setVisible(visible) and non.mouse.isVisible()
75 | - added non.keyboard.setVisible(visible)
76 | - replaced Bitmap (.fnt and .png) with TrueType (.ttf) font support
77 | - changed non.network.client() to non.network.client(timeout, ipAddress, tcpPort, udpPort)
78 | - changed non.network.server() to non.network.server(tcpPort, udpPort)
79 | - changed non.width() to non.graphics.getWidth()
80 | - changed non.height() to non.graphics.getHeight()
81 | - added persistent preferences to non.system
82 | - changed non.accelerometer, non.keyboard, non.mouse and non.touch API a bit
83 | - changed non.graphics.measureText(text, wrap) to non.graphics.getTextBounds(text, wrap)
84 | - added non.graphics.getImageBounds(image)
85 | - fixed non.accelerometer module
86 | - fixed displaying of error logs in console
87 | - fixed small mouse input bug
88 | - fixed some scope related bugs in modules
89 | - fixed -1 exit code when calling non.system.quit() method
90 | - removed Java-side object creation in render() calls (you won't notice change on desktop, but on Android and iOS this speed ups engine a bit)
91 | - added possibility to sign desktop executables (works same as signing android APK)
92 | - changed android.sign config.yml property to just sign (because of above update)
93 | - now only assets required for specified platform are updated (speeds up build times)
94 | - reduced preserverd java globals for non lua scripts (reduced from NON_NON, NON_GDX, NON_MODULE and NON_INPUT to only NON)
95 | - added android.permission.WRITE_EXTERNAL_STORAGE to enable using "external" in non.files on Android devices
96 | - now config.yml properties are loaded and set before window is opened or activity started
97 | - restructured source code to be more readable for possible contributors
98 | - speeded up CLI launcher by few miliseconds
99 | - fixed minimize and close crashes on Android and iOS
100 | - fixed "non update" command
101 | - fixed bug with non.graphics.setColor and non.graphics.setBackgroundColor (green and blue values was swapped)
102 |
103 | [0.6.1]
104 | - now "non start" and "non build" platform defaults to "desktop"
105 | - fixed few bugs what I accidentally made in previous release
106 |
107 | [0.6.0]
108 | - changed API a bit to match Lua standards
109 | - desktop window is now not resizeable
110 | - removed Ruby support (this drastically speeded-up built times)
111 | - added MoonScript support
112 | - renamed "data" folder to "assets" folder because of MoonScript compiler
113 | - now loading screen background is positioned in top-left corner and not in bottom-left corner
114 |
115 | [0.5.0]
116 | - published NON to LuaRocks
117 | - fixed hello task on first run (before you needed to execute it twice to actually generate hello world game)
118 | - added Lua support (same API, just snake_case changed to camelCase)
119 | - changed :position and :size parameters of NON.graphics.draw to :x, :y, :width and :height
120 | - changed :position parameter for NON.graphics.print to :x and :y
121 | - changed float colors to byte colors
122 | - new API for drawing shapes
123 | - added option to load music, sound, image, font and shader instances from different path sources (internal, local...)
124 | - changed NON.clipboard.get_contents and NON.clipboard.set_contents to NON.get_clipboard and NON.set_clipboard
125 | - changed versioning (previous versioning was misleading and indicated that NON isn´t in early development)
126 | - new loading screen background to match website
127 | - added some new methods to NON.graphics - set_background_color, get_background_color, get_shader and get_blending
128 | - removed NON.graphics.clear
129 | - now NON.graphics.get_color returns array and not Color object (so you can do "r, g, b, a = NON.graphics.get_color")
130 | - removed NON.physics, NON.lights and NON.particles module (temporary, will be added back in next updates)
131 | - fixed resetting of color each update before draw() callback
132 | - fixed NON.graphics.translate, NON.graphics.rotate and NON.graphics.scale methods
133 | - finished API for NON.files module
134 | - finished API for NON.audio module
135 | - fixed resizing of game window on desktop platforms
136 | - removed NON.files.parse_json, NON.files.parse_yaml and NON.files.parse_xml (temporary, will be added back in next updates)
137 | - renamed close() callback to quit() callback
138 | - fixed NON.keyboard.show, NON.keyboard.hide, NON.mouse.show and NON.mouse.hide
139 |
140 | [0.4.10]
141 | - moved all modules to root NON module (f.e Graphics is now NON.graphics)
142 | - fixed NON.accelerometer methods (getX, getY, getRotation => x, y, rotation)
143 | - moved methods from App module to root NON module (f.e App.quit is now NON.quit)
144 | - split render(delta) event to draw and update(delta) events
145 | - added measure_text(text, wrap = nil) to graphics module
146 | - renamed loading.png to logo.png, loading_bg.png to bg.png, and loading_bar to bar.png
147 | - changed project structure
148 | - changed default logo, background and icon
149 | - fixed resizing of large background images for loading screen
150 | - changed resize method of loading screen background from fit to cover
151 | - changed loading screen, now it is displaying progress messages
152 | - added parse_yaml, parse_json and parse_xml to NON.files
153 | - removed init(assets) event
154 | - now Ruby stacktrace is displayed in nice way without Java flood
155 | - removed some messy log messages from Gradle
156 | - fixed Gradle runner (was throwing null pointer exception at end of build)
157 | - added joints to NON.physics
158 |
159 | [0.4.9]
160 | - new API for asset loading
161 | - added sound and music methods to Audio module
162 | - renamed Particles.load to Particles.effect
163 |
164 | [0.4.8]
165 | - physics body properties changed to snake_case
166 |
167 | [0.4.7]
168 | - fixed YAML on Android (previous patch was not working)
169 | - removed App.thread method, now Thread works as in normal Ruby
170 | - now ruby runtime is properly terminated when app closes. This fixes mainly activity shutdown and reopen crashes on Android and prevents memory leaks
171 | - renamed most methods from camelCase to snake_case
172 | - renamed some methods totally (like getX to x, setPosition to move, isDown to down)
173 |
174 | [0.4.6]
175 | - removed some temporary files what I forgot to remove
176 | - removed some debug code what I forgot to remove
177 | - small API changes for Graphics.print, Graphics.draw, Graphics.fill and Physics.fixture
178 | - moved some more Java code to Ruby
179 | - updated default logo, icons and loading screen
180 | - added automatic icon resizing. Now, instead of adding custom icon to project/non for each required icon dimension for each platform, compiler will resize one icon.png with reccomened size of 512x512 pixels to correct dimensions required by specified platform
181 | - updated splash screens for iOS platforms
182 | - moved loading bar to bottom of screen
183 | - fixed major bug with Application module
184 | - fixed major bug with YAML loading on Android. This caused to crash of projects trying to load config.yml on Android devices
185 | - forgot to remove stdlib dependency, so now it is done
186 | - added comparison checks for assets. Before, each time project was built, all assets was copied. Now compiler checks if they are modified
187 | - added "clean" task to CLI
188 | - removed --compile flag for start task
189 |
190 | [0.4.5]
191 | - added --compile (example: non build desktop --compile) flag which will set that all ruby code is compiled to java bytecode during build. This means performance almost equal to native Ruby (sometimes even faster) but this also means a bit slower start and build tasks. Then to force load your optimized code, just add .class suffix when using require method
192 | - removed ALL ruby builtin and standard libraries for maximum performamce and cross-platform compatibility. Anyways, NÖN is a game engine, and all important is included in it's own libraries
193 | - fixed few small bugs with non.launcher and joined some tasks together, so this should descrease build time by few seconds
194 | - now resolveDependencies task is executed only when NÖN version changes and not before every task
195 | - improved ruby backtrace (now displays only important messages)
196 | - fixed small networking bug caused by sharing same listener instance between both client and server
197 | - fixed small bug where compiler was creating empty "project" folder on wrong location
198 | - merged non.launcher and non source code for easy building with single "rake" command
199 |
200 | [0.4.4]
201 | - added stdlib support (not tested)
202 | - added physics module back
203 | - some small API changes for physics and lights module
204 | - rewrote audio, keyboard, mouse, accelerometer and touch modules in Ruby
205 | - fixed big android bug with resource files about what I forgot before
206 | - another structure changes of source code
207 | - speeded up build times a bit by removing unnecessary gradle projects
208 | - removed time module (not needed cause of Ruby) and GUI module
209 | - added app module
210 |
211 | [0.4.3]
212 | - changed directory structure and removed auto-updater as this now handles RubyGems
213 | - new event API
214 | - updated Android plugin to 1.1.0 version
215 | - updated Gradle to 2.3
216 |
217 | [0.4.2]
218 | - moved from JavaScript scripting backend to Ruby
219 | - moved Non to RubyGems, easier and automated installation, actual command-line interface (replaced 'java -jar non.jar" with simply "non")
220 | - changed configuration file format from JSON to YAML
221 |
222 | [0.4.1]
223 | - renamed setGraphics(..) method from GUI and particles module to link(..) method
224 | - renamed particleLoader from particles module to effectLoader
225 | - renamed load(..) method from particles module to effect(..)
226 | - added particles sample (usage gen:particles)
227 | - added non.time module
228 | - added threading (usage in scripts: "non.thread(function);" )
229 | - added contacts() method to physics module
230 | - now desktop window title is changed correctly
231 |
232 | [0.4.0]
233 | - added self variable to classes
234 | - added particles module (non.particles)
235 | - last API changes for Joints in physics module
236 | - fixed lights module API to match new physics and graphics API introduced in 3.9.0 update
237 | - updated physics example to match new API changes
238 | - removed graphics parameter from gui renderer and added setGraphics(..) method to GUI module
239 | - loading screen resources are now properly cleared after game is loaded
240 | - optimized game rendering code
241 | - now not only assets loading but also game core loading (scripts, configuration) is shown on loading screen
242 | - changed non.getPlatform() method to non.platform variable
243 | - added non.config variable
244 | - optimized rhino engine
245 |
246 | [0.3.13]
247 | - added vscroll (vertical scrollbar) to GUI module
248 | - added hscroll (horizontal scrollbar) to GUI module
249 | - updated GUI sample
250 | - fixed few bugs in GUI system
251 | - added lights demonstration to physics sample
252 | - added pointAtLight(x, y) and pointAtShadow(x, y) to lights module. These methods tests if specified point is in light or in shadow. Usefull for roguelike games.
253 | - refactored source code as possible preparation to add web support via GWT
254 | - added back non.getPlatform() what I accidentally removed before
255 | - fixed build script to actually include correct .js files from res/ folder
256 | - fixed build script to check for changed icons and loading screen in project res/ folder
257 | - removed android.permission.VIBRATE as this feature is no longer in Non
258 | - added cache clearing to build.gradle
259 | - added android.permission.INTERNET to enable non.networking module
260 | - added Network sample (usage gen:network)
261 | - fixed non key events to match keyboard module key events
262 |
263 | [0.3.12]
264 | - created GUI sample (usage java -jar non.jar gen:gui)
265 | - added setVisible(boolean) method to keyboard and mouse modules
266 | - added measureText(text) and measureText(text, width) methods to graphics module
267 | - started working on GUI system (for now only button, label and text box)
268 | - overhauled physics and graphics module (read wiki again please)
269 | - fixed Pong example
270 | - speeded up engine (at start it is slower than before, but after "warming up" it is a bit faster)
271 | - changed non.touchdown(position, pointer, button) to non.touchdown(x, y, pointer, button)
272 | - changed non.touchup(position, pointer, button) to non.touchup(x, y, pointer, button)
273 | - changed non.touchdragged(position, pointer) to non.touchdragged(x, y, pointer)
274 | - changed non.mousemoved(position) to non.mousemoved(x, y)
275 | - fixed non.keytyped(character) event
276 | - added support for setBlending from strings (additive, alpha, subtractive, multiplicative, premultiplied, replace, screen)
277 | - added uniqueNumber and uniqueString methods to math module
278 | - added getTint() method to graphics module
279 |
280 | [0.3.11]
281 | - added destroy(..) method for destroying bodies and joints to physics (usage physics.destroy(joint) or physics.destroy(body))
282 | - added many new methods to physics module for different types of joints and joint definitions
283 | - added physics example (usage java -jar non.jar gen:physics)
284 | - added example of require function (usage java -jar non.jar gen:require)
285 | - added support for classes to JavaScript engine (read Wiki for example usage)
286 | - removed CoffeeScript support, now engine only supports JavaScript
287 | - renamed non.cfg to config.json to actually show in what language is it and to support external editors
288 | - removed plugin system, replaced it with module system introduced in last patch (prefix "non" is used for determining non modules)
289 | - moved non.buffer to network.buffer
290 | - split input module to parts, so now f.e input.keyboard is keyboard, input.mouse is mouse etc
291 | - fixed bug when clearing screen via graphics.clear method caused to erase all text from screen permanently (now calling clear method is required before drawing anything on screen and not optional as before)
292 | - added queryAABB method to physics
293 | - optimized calling of functions from scripts by storing them properly in variables
294 | - fixed unproject method from graphics module
295 |
296 | [0.3.10]
297 | - added awesome method of handling multiple script files similar to node.js
298 | - removed non.require as it was never working
299 | - moved launcher source code to separate repository to decrease amount of downloaded data for each update and to split versioning of launcher and Non
300 | - added checks for outdated non.jar version
301 | - replaced Lua support with CoffeeScript and optional JavaScript
302 | - removed support for custom scripting languages (sorry folks :/)
303 | - removed need of adding "language" to non.cfg
304 |
305 | [0.3.9]
306 | - fixed major dependency resolving bug (thanks to Murii for finding it)
307 |
308 | [0.3.8]
309 | - more output logs from gradle
310 | - changed some previous output logs to be more clear
311 | - fixed weird whitespace with warnings
312 | - removed logging of dexing warnings
313 |
314 | [0.3.7]
315 | - fixed desktop:run task finally
316 | - fixed few visual bugs in console
317 |
318 | [0.3.6]
319 | - revamped Non launcher, now it automatically updates your Non version
320 | - renamed hello task from gen:hello to hello
321 |
322 | [0.3.5]
323 | - updated Gradle Android to 0.14.4
324 | - updated RoboVM to 1.0.0-beta-03
325 | - updated LibGDX to 1.5.3
326 | - updated Gradle to 2.2
327 | - revamped physics plugin again (read Physics and Box2D section on Wiki)
328 | - added support for fixtures to physics plugin
329 | - renamed non.getWidth to non.width
330 | - renamed non.getHeight to non.height
331 | - renamed non.getConfig to non.config
332 | - renamed non.getDelta to non.delta
333 | - renamed non.getFPS to non.fps
334 | - renamed non.checkPlatform to non.platform
335 | - removed non.getPlatform
336 | - fixed android:run task (read Running and packaging a project section on Wiki)
337 | - fixed loading of physics plugin
338 | - fixed bug where gradlew was not recognized as executable on Unix systems
339 | - fixed major bug with handling mouse and touch input
340 | - optimized console launcher a bit
341 | - fixed bug when task fails, it was not recognizing it until all tasks ended
342 | - console now properly ignores fake errors from LuaJ and Rhino libraries (Lua and JavaScript)
343 |
344 | [0.3.4]
345 | - added proper loading animation for Non command line
346 | - added getPosition method to input.touch
347 | - added option for hiding mouse (desktop only) with show() and hide() methods
348 | - added automatic dependency loading to plugins
349 |
350 | [0.3.3]
351 | - simplified logging of non.jar CLI
352 | - added support for multi-threading for JavaScript, not yet working on Lua
353 | - fixed translate method in graphics plugin
354 | - added project and unproject method to graphics plugin
355 | - now logging functions do not return values (was returning always NULL)
356 | - removed warning logging level
357 | - error logging level do not force quit application
358 | - tweaked default log messages a bit
359 | - added setting for log level to non.cfg
360 | - fixed networking
361 | - semi-fixed desktop:run task from CLI (still failing to load resources)
362 | - now update task from CLI properly clears unused plugins and languages
363 | - plugin loader now uses reflection and not initializer class what was generated by gradle
364 | - because of above update, moved all internal plugins from "non.plugins.internal" to "non.plugins" package
365 | - added checks for missing configurations from non.cfg
366 | - added checks for missing resources
367 | - added checks for missing plugins
368 |
369 | [0.3.2]
370 | - revamped Non launcher, now only non.jar is required (this also changed some commands, so please read again the Wiki)
371 | - fixed bug what caused that mobile devices thought that all apps made by non are same (so when you tried to install 2 different Non projects on your device, second one simply replaced first one)
372 | - added "package" property to non.cfg
373 | - added sqrt() to math plugin
374 | - added pow() to math plugin
375 |
376 | [0.3.1]
377 | - added non.buffer what can be used for reading and writing data to and from byte array
378 | - added checks for not existing functions to scripting
379 | - added more features to math plugin
380 | - added get() method to scripting
381 | - revamped physics plugin
382 | - removed "raw" argument for loading assets, now it is automatically determined if file should be loaded directly or via asset loader
383 | - removed init() method from scripting
384 | - replaced hacky networking with KryoNet (still WIP, some threading issues with scripting)
385 |
386 | [0.3.0]
387 | - added drawing of various shapes to graphics plugin
388 | - added new method to graphics plugin for drawing formatted text (printf)
389 | - added new method to graphics plugin for drawing texture quad (drawq)
390 | - added 2 new examples to gen task: Hello World and Pong
391 | - added line and quad to math plugin
392 | - added support for custom scripting languages
393 | - changed non.cfg "main" to "language" and changed its functionality
394 | - removed input.keyboard.isKeyJustPressed
395 | - removed input.touch.isJustTouched
396 | - removed input.mouse.isJustClicked
397 | - renamed graphics.texture to graphics.imageLoader
398 | - renamed graphics.font to graphics.fontLoader
399 | - renamed audio.sound to audio.soundLoader
400 | - renamed audio.music to audio.musicLoader
401 | - renamed graphics.newTexture to graphics.image
402 | - renamed graphics.newFont to graphics.color
403 | - renamed graphics.newShader to graphics.shader
404 | - renamed graphics.newColor to graphics.color
405 | - renamed graphics.setBackground to graphics.clear
406 | - renamed graphics.setColor to graphics.tint
407 | - renamed input.keyboard.isKeyPressed to input.keyboard.isDown
408 | - renamed input.touch.isTouched to input.touch.isDown
409 | - renamed input.mouse.isClicked to input.mouse.isDown
410 | - renamed math.newVector to math.vector
411 | - renamed math.newRectangle to math.rectangle
412 | - renamed math.newCircle to math.circle
413 | - renamed math.newPolygon to math.polygon
414 | - renamed math.newPolyline to math.polyline
415 | - renamed network.newServer and network.newClient to network.server and network.client
416 | - renamed physics.newShape to physics.shape
417 | - removed need for using graphics.begin and graphics.display when drawing anything
418 | - fixed graphics.translate and graphics.rotate
419 | - fixed calling of resize event
420 |
421 | [0.2.0]
422 | - added asynchromous resource loading (use non.load(assets) event) along with super sexy loading screen what is displayed during loading
423 | - removed TILED support (sorry, I wasn´t able to make it work with normal coordinate system)
424 | - totally revamped graphics, audio and input plugin
425 | - added some new events for handling input
426 | - removed need of entire res/ folder for new projects
427 | - fixed major bug with Lua integration what I do not noticed before
428 | - added non.exit method what will quit current game
429 | - added option for changing display mode for desktop from non.cfg
430 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2015 nondev
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Yet Another Engine
2 |
3 |
5 |
6 | > **Kaizo**: Oh! Even someone with a tender face like yours has a great weapon like that! It doesn't fit someone like you!
7 | > **Yae**: Eh? This bazooka?
8 | > **Kaizo**: Yeah! If I had that weapon, I could have the power of a million people! Well, give it to me! Give it to me!
9 |
10 |
11 | An engine you can use to make games in **MoonScript**. It's free, open-source, and works on **Windows**, **Mac OS X**, **Linux**, **Android**, **iOS** and **Ouya**.
12 |
13 | ### Installation
14 |
15 | ```
16 | luarocks install --server=http://luarocks.org/dev yae
17 | ```
18 |
19 | ### Getting Started
20 |
21 | * [Introduction](https://github.com/yaedev/yae/wiki/Introduction)
22 | * [Create your first project](https://github.com/yaedev/yae/wiki/Getting-started)
23 | * [Run, Manage and Package your project]( https://github.com/yaedev/yae/wiki/Running-and-packaging-your-project)
24 | * [Read the Wiki](https://github.com/yaedev/yae/wiki)
25 |
26 | ### Documentation
27 |
28 | The [Wiki](https://github.com/yaedev/yae/wiki) contains all the information you'll need to write game. You can contribute to the Wiki directly here on GitHub! Also, you can view [online documentation](https://yae.io/doc/) generated right from the source code.
29 |
30 | ### Reporting Issues
31 |
32 | Use the [issue tracker](https://github.com/yaedev/yae/issues) here on GitHub to report issues.
33 |
--------------------------------------------------------------------------------
/bin/yae:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env lua
2 |
3 | local cfg = require("luarocks.cfg")
4 | local fs = require("luarocks.fs")
5 | local workingPath = fs.current_dir().."/"
6 | local enginePath = debug.getinfo(1,"S").source:match("(.*/)"):sub(2, -5)
7 | local gradlew = cfg.platforms.windows and "gradlew" or "./gradlew"
8 | local tempPath = ".yae/"
9 | local configFile = "project.yml"
10 | local needsClean = false
11 |
12 | local function copy(source, dest)
13 | local src = enginePath..source
14 | local dst = workingPath..dest
15 |
16 | if fs.is_dir(src) then
17 | fs.make_dir(dst)
18 | fs.copy_contents(src, dst)
19 | else
20 | fs.copy(src, dst)
21 | end
22 | end
23 |
24 | local function exec(args, quiet)
25 | if (needsClean) then
26 | args = "clean "..args
27 | needsClean = false
28 | end
29 |
30 | fs.change_dir(workingPath..tempPath)
31 | if quiet then
32 | fs.execute_quiet(gradlew.." "..args)
33 | else
34 | fs.execute(gradlew.." "..args)
35 | end
36 | end
37 |
38 | local function mkex(file)
39 | fs.chmod(workingPath..file, "777")
40 | end
41 |
42 | local function read(file)
43 | local f = io.open(file, "rb")
44 | local content = f:read("*all")
45 | f:close()
46 | return content
47 | end
48 |
49 | local function version()
50 | return read(enginePath.."core/VERSION")
51 | end
52 |
53 | local function check(msg, normal)
54 | if arg[1] ~= "new" and not fs.exists(workingPath..configFile) then
55 | print("No project found.")
56 | os.exit(-1)
57 | end
58 |
59 | if arg[1] == "new" and fs.exists(workingPath..configFile) then
60 | print("Project already exists.")
61 | os.exit(-1)
62 | end
63 |
64 | if not normal then
65 | msg = msg:upper()
66 | end
67 |
68 | print(msg)
69 |
70 | if fs.exists(workingPath..tempPath) then
71 | return
72 | end
73 |
74 | copy("core", tempPath)
75 | copy("res", tempPath.."res")
76 | copy("src/build/classes", tempPath.."shared/precompiled")
77 | mkex(tempPath.."gradlew")
78 | mkex(tempPath.."shared/precompile")
79 | needsClean = true
80 | end
81 |
82 | local function help()
83 | print("Commands:");
84 | print(" yae new PROJECT # initializes new project")
85 | print(" yae run PLATFORM # start your project")
86 | print(" yae build BUILD_PLATFORM # build your project")
87 | print(" yae clean # clean temporary data for your project")
88 | print(" yae update # update your project's runtime version and dependencies")
89 | print(" yae forceupdate # force update your project's runtime version and dependencies")
90 | print(" yae version # print current compiler version")
91 | print("")
92 | print("PROJECT can be any string (default 'My Project')")
93 | print("PLATFORM can be 'desktop', 'android' or 'ios' (default 'desktop')")
94 | print("BUILD_PLATFORM can be 'desktop', 'android' 'ios', 'windows', 'linux', 'mac' (default 'desktop')")
95 | os.exit(-1)
96 | end
97 |
98 | if arg[1] == "build" then
99 | check("Building your project")
100 |
101 | if #arg < 2 or arg[2] == "desktop" then
102 | exec("update updateDesktop desktop:dist")
103 | elseif arg[2] == "android" then
104 | exec("update updateAndroid android:dist")
105 | elseif arg[2] == "ios" then
106 | exec("update updateIOS ios:dist")
107 | elseif arg[2] == "windows" then
108 | exec("update updateDesktop desktop:dist desktop:windows")
109 | elseif arg[2] == "linux" then
110 | exec("update updateDesktop desktop:dist desktop:linux")
111 | elseif arg[2] == "mac" then
112 | exec("update updateDesktop desktop:dist desktop:mac")
113 | else
114 | help()
115 | end
116 | elseif arg[1] == "run" then
117 | check("Starting your project")
118 |
119 | if #arg < 2 or arg[2] == "desktop" then
120 | exec("update updateDesktop desktop:run")
121 | elseif arg[2] == "android" then
122 | exec("update updateAndroid android:run")
123 | elseif arg[2] == "ios" then
124 | exec("update updateIOS ios:run")
125 | else
126 | help()
127 | end
128 | elseif arg[1] == "new" then
129 | check("Creating new project")
130 | local projname = "My Project"
131 |
132 | if #arg > 1 then
133 | projname = arg[2]
134 | end
135 |
136 | exec("init -PinitName=\""..projname.."\"")
137 | elseif arg[1] == "clean" then
138 | check("Cleaning your project's temporary data")
139 | exec("clean")
140 | elseif arg[1] == "update" then
141 | check("Updating your project's runtime")
142 | local projversion = read(workingPath..tempPath.."VERSION")
143 | local curversion = version()
144 |
145 | if not curversion == projversion then
146 | fs.delete(workingPath..tempPath)
147 | check("Updating your project's runtime to "..curversion, true)
148 | else
149 | print("You are using latest runtime.")
150 | end
151 | elseif arg[1] == "forceupdate" then
152 | fs.delete(workingPath..tempPath)
153 | check("Updating your project's runtime")
154 | elseif arg[1] == "version" then
155 | print(version())
156 | else
157 | help()
158 | end
159 |
--------------------------------------------------------------------------------
/build:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | cd src
3 | moonc -t build/lua .
4 | cd ../
5 | java -cp core/libs/bcel.jar:core/libs/luaj.jar luajc -r -d src/build/classes src/build/lua
--------------------------------------------------------------------------------
/build.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | setlocal
3 | cd src
4 | call moonc -t build\lua .
5 | cd ../
6 | call java -cp core\libs\bcel.jar;core\libs\luaj.jar luajc -r -d src\build\classes src\build\lua
7 | endlocal
--------------------------------------------------------------------------------
/core/VERSION:
--------------------------------------------------------------------------------
1 | v0.7.0
--------------------------------------------------------------------------------
/core/android/build.gradle:
--------------------------------------------------------------------------------
1 | android {
2 | buildToolsVersion "20.0.0"
3 | compileSdkVersion 20
4 | sourceSets {
5 | main {
6 | manifest.srcFile 'AndroidManifest.xml'
7 | java.srcDirs = ['src']
8 | aidl.srcDirs = ['src']
9 | renderscript.srcDirs = ['src']
10 | res.srcDirs = ['res']
11 | assets.srcDirs = ['assets']
12 | }
13 |
14 | instrumentTest.setRoot('tests')
15 | }
16 |
17 | defaultConfig {
18 | minSdkVersion 14
19 | targetSdkVersion 20
20 | }
21 |
22 | try {
23 | signingConfigs {
24 | releaseSigning {
25 | storeFile file(cfg.sign.storeFile)
26 | storePassword cfg.sign.storePassword
27 | keyAlias cfg.sign.keyAlias
28 | keyPassword cfg.sign.keyPassword
29 | }
30 | }
31 | } catch(e) {
32 | signingConfigs {
33 | releaseSigning {
34 | storeFile file("../debug.keystore")
35 | storePassword "nononsense"
36 | keyAlias "non"
37 | keyPassword "nononsense"
38 | }
39 | }
40 | }
41 |
42 | buildTypes {
43 | release {
44 | signingConfig signingConfigs.releaseSigning
45 | }
46 | }
47 | }
48 |
49 | tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
50 | pkgTask.jniFolders = new HashSet()
51 | pkgTask.jniFolders.add(new File(projectDir, 'libs'))
52 | }
53 |
54 | task run(type: Exec, dependsOn: ':android:installDebug') {
55 | Properties properties = new Properties()
56 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
57 | def sdkDir = properties.getProperty('sdk.dir')
58 | commandLine sdkDir + "/platform-tools/adb", 'shell', 'am', 'start', '-n', "${packageName}.android/${packageName}.android.AndroidLauncher"
59 | }
60 |
61 | task copyNatives() << {
62 | file("libs/armeabi/").mkdirs();
63 | file("libs/armeabi-v7a/").mkdirs();
64 | file("libs/x86/").mkdirs();
65 |
66 | configurations.natives.files.each { jar ->
67 | def outputDir = null
68 | if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
69 | if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
70 | if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
71 | if(jar.name.endsWith("natives-android.jar")) outputDir = file("libs")
72 | if(outputDir != null) {
73 | copy {
74 | from zipTree(jar)
75 | into outputDir
76 | include "**/*.so"
77 | }
78 | }
79 | }
80 | }
81 |
82 | task dist(dependsOn: assembleRelease) << {
83 | file("../../build/android").mkdirs()
84 |
85 | copy {
86 | from "build/outputs/apk"
87 | into "../../build/android"
88 | include "android-release-unsigned.apk"
89 | rename "android-release-unsigned.apk", "${appName} v${version}.apk"
90 | }
91 |
92 | copy {
93 | from "build/outputs/apk"
94 | into "../../build/android"
95 | include "android-release.apk"
96 | rename "android-release.apk", "${appName} v${version}.apk"
97 | }
98 |
99 | println "You can find ${appName} v${version}.apk in /build/android"
100 | }
101 |
--------------------------------------------------------------------------------
/core/android/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
--------------------------------------------------------------------------------
/core/build.gradle:
--------------------------------------------------------------------------------
1 | import static java.awt.RenderingHints.*
2 | import java.awt.image.BufferedImage
3 | import javax.imageio.ImageIO
4 | import java.text.Normalizer
5 | import org.yaml.snakeyaml.Yaml
6 |
7 | configure()
8 |
9 | buildscript {
10 | repositories {
11 | mavenCentral()
12 | jcenter()
13 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
14 | }
15 |
16 | dependencies {
17 | classpath 'com.android.tools.build:gradle:1.3.1'
18 | classpath 'org.robovm:robovm-gradle-plugin:1.6.0'
19 | classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
20 | classpath 'org.yaml:snakeyaml:1.16'
21 | classpath 'com.badlogicgames.packr:packr:1.3-SNAPSHOT'
22 | }
23 | }
24 |
25 | apply plugin: "base"
26 |
27 | allprojects {
28 | version = cfg.version
29 |
30 | ext {
31 | cfg = cfg
32 | appName = cfg.name
33 | packageName = cfg.package
34 | packageDir = cfg.package.replace('.', '/')
35 | gdxVersion = '1.6.4'
36 | roboVMVersion = '1.6.0'
37 | screenOrientation =
38 | cfg.window && cfg.window.orientation ?
39 | cfg.window.orientation : "sensor"
40 | vals = [[
41 | "%APP_NAME%",
42 | "%PACKAGE%",
43 | "%PACKAGE_DIR%",
44 | "%SCREEN_ORIENTATION%"
45 | ],[
46 | appName,
47 | packageName,
48 | packageDir,
49 | screenOrientation
50 | ]]
51 | }
52 |
53 | repositories {
54 | mavenCentral()
55 | mavenLocal()
56 | maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
57 | maven { url "https://oss.sonatype.org/content/repositories/releases/" }
58 | }
59 | }
60 |
61 | project(":shared") {
62 | apply plugin: "java"
63 |
64 | dependencies {
65 | compile files("../libs/luaj.jar")
66 | compile files("../libs/snakeyaml.jar")
67 | compile "com.badlogicgames.gdx:gdx:$gdxVersion"
68 | compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
69 | compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
70 | if (cfg.libs) { for (lib in cfg.libs) { compile lib } }
71 | }
72 | }
73 |
74 | project(":desktop") {
75 | apply plugin: "java"
76 |
77 | dependencies {
78 | compile project(":shared")
79 | compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
80 | compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
81 | compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
82 | compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
83 | }
84 | }
85 |
86 | project(":android") {
87 | apply plugin: "android-sdk-manager"
88 | apply plugin: "android"
89 |
90 | configurations { natives }
91 |
92 | dependencies {
93 | compile project(":shared")
94 | compile files("../libs/luaj.jar")
95 | compile files("../libs/snakeyaml.jar")
96 | compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
97 | natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
98 | natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
99 | natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
100 | compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
101 | natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
102 | natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
103 | natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
104 | natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
105 | natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
106 | natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
107 | }
108 | }
109 |
110 | project(":ios") {
111 | apply plugin: "java"
112 | apply plugin: "robovm"
113 |
114 | dependencies {
115 | compile project(":shared")
116 | compile files("../libs/luaj.jar")
117 | compile files("../libs/snakeyaml.jar")
118 | compile "org.robovm:robovm-rt:${roboVMVersion}"
119 | compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
120 | compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
121 | compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
122 | compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
123 | compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
124 | }
125 | }
126 |
127 | task cleanAssets() << {
128 | deldir file("android/assets")
129 | deldir file("shared/build/lua")
130 | }
131 |
132 | clean.dependsOn cleanAssets
133 |
134 | task init() << {
135 | file("../assets").mkdir()
136 |
137 | def origpname = initName.replace('"', "")
138 | def pname = Normalizer
139 | .normalize(origpname, Normalizer.Form.NFD)
140 | .replace(" ", "")
141 | .replaceAll("[^\\p{ASCII}]", "")
142 | .toLowerCase()
143 |
144 | def origuname = System.getProperty("user.name", "username")
145 | def uname = Normalizer
146 | .normalize(origuname, Normalizer.Form.NFD)
147 | .replace(" ", "")
148 | .replace(".", "")
149 | .replace("_", "")
150 | .replace("-", "")
151 | .replaceAll("[^\\p{ASCII}]", "")
152 | .toLowerCase()
153 |
154 | def text =
155 | "name: ${origpname}\n" +
156 | "package: com.${uname}.${pname}\n" +
157 | "version: 1.0"
158 |
159 | new File("../project.yml").text = text
160 | copy { from "res"; into "../assets"; include "main.moon" }
161 | copy { from "res"; into "../"; include ".gitignore" }
162 | }
163 |
164 | task rocks() << {
165 | if (!cfg.rocks) return
166 |
167 | for (rock in cfg.rocks) {
168 | exec { commandLine "luarocks", "install", rock, "--tree=rocks" }
169 | }
170 | }
171 |
172 | task update(dependsOn: [':rocks', ':updateAssets']) << {
173 | if (!file("shared/build/moon").exists()) {
174 | file("shared/build/moon").mkdirs();
175 | }
176 |
177 | def src = ".."
178 | def res = "res"
179 | def out = "android/assets/yae"
180 | def files = [ "icon.png", "font.ttf" ]
181 |
182 | for(fl in files) {
183 | if (file("$src/$fl").exists()) {
184 | copy { from src; into out; include "$fl" }
185 | } else {
186 | copy { from res; into out; include "$fl" }
187 | }
188 | }
189 |
190 | def scfg = new Yaml().load(file("$src/project.yml").text)
191 |
192 | if (scfg.sign) {
193 | scfg.sign = "private"
194 | }
195 |
196 | def cfgf = file("$out/project.yml")
197 | if (cfgf.exists()) cfgf.delete()
198 | cfgf.createNewFile()
199 | cfgf.text = new Yaml().dump(scfg)
200 | }
201 |
202 | task updateDesktop() << {
203 | def out = "android/assets/yae"
204 | copyAndReplace("platforms/desktop/DesktopLauncher.java", "desktop/src/$packageDir/desktop/DesktopLauncher.java")
205 | copyAndResizeIcon("${out}/icon-16.png", 16)
206 | copyAndResizeIcon("${out}/icon-32.png", 32)
207 | copyAndResizeIcon("${out}/icon-64.png", 64)
208 | copyAndResizeIcon("${out}/icon-192.png", 192)
209 | copyAndResizeIcon("${out}/icon-256.png", 256)
210 | }
211 |
212 | task updateAndroid(dependsOn: 'android:copyNatives') << {
213 | copyAndReplace("platforms/android/AndroidManifest.xml", "android/AndroidManifest.xml")
214 | copyAndReplace("platforms/android/AndroidLauncher.java", "android/src/$packageDir/android/AndroidLauncher.java")
215 | copyAndResizeIcon("android/res/drawable-mdpi/ic_launcher.png", 48)
216 | copyAndResizeIcon("android/res/drawable-hdpi/ic_launcher.png", 72)
217 | copyAndResizeIcon("android/res/drawable-xhdpi/ic_launcher.png", 96)
218 | copyAndResizeIcon("android/res/drawable-xxhdpi/ic_launcher.png", 144)
219 | copyAndResizeIcon("android/ic_launcher-web.png", 512)
220 | }
221 |
222 | task updateIOS() << {
223 | copyAndReplace("platforms/ios/robovm.properties", "ios/robovm.properties")
224 | copyAndReplace("platforms/ios/IOSLauncher.java", "ios/src/$packageDir/ios/IOSLauncher.java")
225 | copyAndResizeIcon("ios/data/Icon.png", 57)
226 | copyAndResizeIcon("ios/data/Icon-72.png", 72)
227 | copyAndResizeIcon("ios/data/Icon@2x.png", 114)
228 | copyAndResizeIcon("ios/data/Icon-72@2x.png", 144)
229 | }
230 |
231 | task updateAssets(type: Sync) {
232 | from "../assets"
233 | into "android/assets"
234 | exclude "**/*.moon"
235 | exclude "**/*.lua"
236 | exclude "**/*.DS_Store"
237 | exclude "**/*Thumbs.db"
238 | }
239 |
240 | def configure() {
241 | def f = file("../project.yml")
242 |
243 | if (f.exists()) {
244 | ext.cfg = new Yaml().load(f.text)
245 | } else {
246 | ext.cfg = new Yaml().load(
247 | "name: yae\n" +
248 | "package: yae\n" +
249 | "version: 1.0"
250 | )
251 | }
252 | }
253 |
254 | def deldir(file) {
255 | if(file.exists()) {
256 | def files = file.listFiles();
257 |
258 | if(files != null) {
259 | for(File fl: files) {
260 | if(fl.isDirectory()) {
261 | deldir(fl)
262 | } else {
263 | fl.delete()
264 | }
265 | }
266 | }
267 | }
268 |
269 | file.delete()
270 | }
271 |
272 | def copyAndReplace(input, out) {
273 | def values = ext.vals
274 | def total = values[0].size() - 1
275 | def txt = file(input).text
276 |
277 | for(i in 0..total) {
278 | txt = txt.replace(values[0][i], values[1][i])
279 | }
280 |
281 | out = new File(out)
282 | if (out.exists()) out.delete()
283 | out.getParentFile().mkdirs()
284 | out.createNewFile()
285 | out.write(txt)
286 | }
287 |
288 | def copyAndResizeIcon(targetPath, newSize) {
289 | def source = file("../icon.png").exists() ? file("../icon.png") : file("res/icon.png")
290 | def target = new File(targetPath)
291 | if (target.exists()) target.delete()
292 | target.getParentFile().mkdirs()
293 | target.createNewFile()
294 |
295 | def img = ImageIO.read(source)
296 |
297 | new BufferedImage(newSize, newSize, img.type).with {
298 | i -> createGraphics().with {
299 | setRenderingHint( KEY_INTERPOLATION, VALUE_INTERPOLATION_BICUBIC )
300 | drawImage(img, 0, 0, newSize, newSize, null)
301 | dispose()
302 | }
303 |
304 | ImageIO.write(i, 'png', target)
305 | }
306 | }
307 |
--------------------------------------------------------------------------------
/core/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/core/debug.keystore
--------------------------------------------------------------------------------
/core/desktop/build.gradle:
--------------------------------------------------------------------------------
1 | import com.badlogicgames.packr.Packr
2 |
3 | sourceCompatibility = 1.7
4 | sourceSets.main.java.srcDirs = [ "src/" ]
5 |
6 | project.ext.mainClassName = "${packageName}.desktop.DesktopLauncher"
7 | project.ext.assetsDir = new File("../android/assets")
8 |
9 | task run(type: JavaExec, dependsOn: classes) {
10 | main = project.mainClassName
11 | classpath = sourceSets.main.runtimeClasspath
12 | standardInput = System.in
13 | workingDir = project.assetsDir
14 | }
15 |
16 | task windows() << {
17 | def config = new Packr.Config()
18 | config.platform = Packr.Platform.windows
19 | config.jdk = "https://bitbucket.org/alexkasko/openjdk-unofficial-builds/downloads/openjdk-1.7.0-u80-unofficial-windows-i586-image.zip"
20 | config.executable = appName
21 | config.jar = file("build/libs/desktop-${version}.jar").absolutePath
22 | config.mainClass = project.mainClassName.replace(".", "/")
23 | config.vmArgs = ["-Xmx1G"]
24 | config.outDir = file("../../build/windows").absolutePath
25 | new Packr().pack(config)
26 | }
27 |
28 | task linux() << {
29 | def config = new Packr.Config()
30 | config.platform = Packr.Platform.linux32
31 | config.jdk = "https://bitbucket.org/alexkasko/openjdk-unofficial-builds/downloads/openjdk-1.7.0-u80-unofficial-linux-i586-image.zip"
32 | config.executable = appName
33 | config.jar = file("build/libs/desktop-${version}.jar").absolutePath
34 | config.mainClass = project.mainClassName.replace(".", "/")
35 | config.vmArgs = ["-Xmx1G"]
36 | config.outDir = file("../../build/linux32").absolutePath
37 | new Packr().pack(config)
38 |
39 | config.platform = Packr.Platform.linux64
40 | config.jdk = "https://bitbucket.org/alexkasko/openjdk-unofficial-builds/downloads/openjdk-1.7.0-u80-unofficial-linux-amd64-image.zip"
41 | config.outDir = file("../../build/linux64").absolutePath
42 | new Packr().pack(config)
43 | }
44 |
45 | task mac() << {
46 | def config = new Packr.Config()
47 | config.platform = Packr.Platform.mac
48 | config.jdk = "https://bitbucket.org/alexkasko/openjdk-unofficial-builds/downloads/openjdk-1.7.0-u80-unofficial-macosx-x86_64-image.zip"
49 | config.executable = appName
50 | config.jar = file("build/libs/desktop-${version}.jar").absolutePath
51 | config.mainClass = project.mainClassName.replace(".", "/")
52 | config.vmArgs = ["-Xmx1G"]
53 | config.outDir = file("../../build/mac").absolutePath + "/${appName} v${version}.app"
54 | new Packr().pack(config)
55 | }
56 |
57 | task dist(type: Jar, dependsOn: classes) {
58 | from files(sourceSets.main.output.classesDir)
59 | from files(sourceSets.main.output.resourcesDir)
60 | from {configurations.compile.collect {zipTree(it)}}
61 | from files(project.assetsDir);
62 |
63 | manifest {
64 | attributes 'Main-Class': project.mainClassName
65 | }
66 |
67 | doLast {
68 | try {
69 | ant.signjar(
70 | jar: file("build/libs/desktop-${version}.jar").absolutePath,
71 | alias: cfg.sign.keyAlias,
72 | keystore: file(cfg.sign.storeFile).absolutePath,
73 | storepass: cfg.sign.storePassword,
74 | keypass: cfg.sign.keyPassword
75 | )
76 | } catch(e) { }
77 |
78 | file("../../build/desktop").mkdirs()
79 |
80 | copy {
81 | from "build/libs"
82 | into "../../build/desktop"
83 | include "desktop-${version}.jar"
84 | rename "desktop-${version}.jar", "${appName} v${version}.jar"
85 | }
86 |
87 | println "You can find ${appName} v${version}.jar in /build/desktop"
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/core/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.daemon=true
2 | org.gradle.jvmargs=-Xms128m -Xmx1024m -XX:MaxPermSize=1024m
3 | org.gradle.configureondemand=true
--------------------------------------------------------------------------------
/core/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradlew.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
--------------------------------------------------------------------------------
/core/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradlew.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/core/gradlew.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/core/gradlew.jar
--------------------------------------------------------------------------------
/core/gradlew.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=http\://services.gradle.org/distributions/gradle-2.3-all.zip
--------------------------------------------------------------------------------
/core/ios/Info.plist.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${app.name}
9 | CFBundleExecutable
10 | ${app.executable}
11 | CFBundleIdentifier
12 | ${app.id}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${app.name}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | ${app.version}
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | ${app.build}
25 | LSRequiresIPhoneOS
26 |
27 | UIViewControllerBasedStatusBarAppearance
28 |
29 | UIStatusBarHidden
30 |
31 | UIDeviceFamily
32 |
33 | 1
34 | 2
35 |
36 | UIRequiredDeviceCapabilities
37 |
38 | armv7
39 | opengles-2
40 |
41 | UISupportedInterfaceOrientations
42 |
43 | UIInterfaceOrientationPortrait
44 | UIInterfaceOrientationLandscapeLeft
45 | UIInterfaceOrientationLandscapeRight
46 |
47 | CFBundleIcons
48 |
49 | CFBundlePrimaryIcon
50 |
51 | CFBundleIconFiles
52 |
53 | Icon
54 | Icon-72
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/core/ios/build.gradle:
--------------------------------------------------------------------------------
1 | sourceSets.main.java.srcDirs = [ "src/" ]
2 | sourceCompatibility = '1.7'
3 | [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
4 | ext.mainClassName = packageName + ".ios.IOSLauncher"
5 |
6 | task run(dependsOn: launchIPhoneSimulator)
7 |
8 | task dist(dependsOn: createIPA) << {
9 | println "You can find ${appName} v${version}.ipa in /build/ios"
10 | }
11 |
12 | launchIPhoneSimulator.dependsOn build
13 | launchIPadSimulator.dependsOn build
14 | launchIOSDevice.dependsOn build
15 | createIPA.dependsOn build
16 |
--------------------------------------------------------------------------------
/core/ios/data/Default-414w-736h@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/core/ios/data/Default-414w-736h@3x.png
--------------------------------------------------------------------------------
/core/ios/data/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/core/ios/data/Default-568h@2x.png
--------------------------------------------------------------------------------
/core/ios/data/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/core/ios/data/Default.png
--------------------------------------------------------------------------------
/core/ios/data/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/core/ios/data/Default@2x.png
--------------------------------------------------------------------------------
/core/ios/data/Default@2x~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/core/ios/data/Default@2x~ipad.png
--------------------------------------------------------------------------------
/core/ios/data/Default~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/core/ios/data/Default~ipad.png
--------------------------------------------------------------------------------
/core/ios/robovm.xml:
--------------------------------------------------------------------------------
1 |
2 | ${app.executable}
3 | ${app.mainclass}
4 | ios
5 | thumbv7
6 | ios
7 | Info.plist.xml
8 |
9 |
10 | ../android/assets
11 |
12 | **
13 |
14 | true
15 |
16 |
17 | data
18 |
19 |
20 |
21 | com.badlogic.gdx.scenes.scene2d.ui.*
22 | com.badlogic.gdx.graphics.g3d.particles.**
23 | com.android.okhttp.HttpHandler
24 | com.android.okhttp.HttpsHandler
25 | com.android.org.conscrypt.**
26 | com.android.org.bouncycastle.jce.provider.BouncyCastleProvider
27 | com.android.org.bouncycastle.jcajce.provider.keystore.BC$Mappings
28 | com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi
29 | com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi$Std
30 | com.android.org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi
31 | com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL
32 | org.apache.harmony.security.provider.cert.DRLCertFactory
33 | org.apache.harmony.security.provider.crypto.CryptoProvider
34 |
35 |
36 | z
37 |
38 |
39 | UIKit
40 | OpenGLES
41 | QuartzCore
42 | CoreGraphics
43 | OpenAL
44 | AudioToolbox
45 | AVFoundation
46 |
47 |
48 |
--------------------------------------------------------------------------------
/core/libs/bcel.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/core/libs/bcel.jar
--------------------------------------------------------------------------------
/core/libs/luaj.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/core/libs/luaj.jar
--------------------------------------------------------------------------------
/core/libs/snakeyaml.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/core/libs/snakeyaml.jar
--------------------------------------------------------------------------------
/core/platforms/android/AndroidLauncher.java:
--------------------------------------------------------------------------------
1 | package %PACKAGE%.android;
2 |
3 | import java.util.Map;
4 | import java.io.InputStream;
5 | import java.io.IOException;
6 | import org.yaml.snakeyaml.Yaml;
7 | import android.os.Bundle;
8 | import com.badlogic.gdx.backends.android.AndroidApplication;
9 | import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
10 | import yae.YaeVM;
11 |
12 | public class AndroidLauncher extends AndroidApplication {
13 | @SuppressWarnings("unchecked")
14 | protected void onCreate (Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
17 |
18 | try {
19 | Map config = (Map)new Yaml().load(getAssets().open("yae/project.yml"));
20 | initialize(new YaeVM(config), cfg);
21 | } catch (IOException e) {
22 | System.err.println(e.getMessage());
23 | System.exit(-1);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/core/platforms/android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/core/platforms/desktop/DesktopLauncher.java:
--------------------------------------------------------------------------------
1 | package %PACKAGE%.desktop;
2 |
3 | import java.io.File;
4 | import java.io.InputStream;
5 | import java.io.FileInputStream;
6 | import java.util.Map;
7 | import org.yaml.snakeyaml.Yaml;
8 | import com.badlogic.gdx.Files;
9 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
10 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
11 | import yae.YaeVM;
12 |
13 | public class DesktopLauncher {
14 | @SuppressWarnings("unchecked")
15 | public static void main (String[] args) {
16 | LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
17 | cfg.addIcon("yae/icon-256.png", Files.FileType.Internal);
18 | cfg.addIcon("yae/icon-192.png", Files.FileType.Internal);
19 | cfg.addIcon("yae/icon-64.png", Files.FileType.Internal);
20 | cfg.addIcon("yae/icon-32.png", Files.FileType.Internal);
21 | cfg.addIcon("yae/icon-16.png", Files.FileType.Internal);
22 | cfg.forceExit = false;
23 | cfg.width = 800;
24 | cfg.height = 600;
25 | cfg.resizable = false;
26 |
27 | Yaml yaml = new Yaml();
28 | Map config;
29 |
30 | try {
31 | config = (Map)yaml.load(DesktopLauncher.class.getResourceAsStream("/yae/project.yml"));
32 | } catch (Exception e1) {
33 | try {
34 | config = (Map)yaml.load(new FileInputStream(new File("yae/project.yml")));
35 | } catch (Exception e2) {
36 | System.err.println(e2.getMessage());
37 | System.exit(-1);
38 | return;
39 | }
40 | }
41 |
42 | cfg.title = (String)config.get("name");
43 |
44 | if (config.containsKey("window")) {
45 | Map window = (Map)config.get("window");
46 | if (window.containsKey("width")) cfg.width = (Integer)window.get("width");
47 | if (window.containsKey("height")) cfg.height = (Integer)window.get("height");
48 | if (window.containsKey("resizable")) cfg.resizable = (Boolean)window.get("resizable");
49 | if (window.containsKey("fullscreen")) cfg.fullscreen = (Boolean)window.get("fullscreen");
50 | }
51 |
52 | new LwjglApplication(new YaeVM(config), cfg);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/platforms/ios/IOSLauncher.java:
--------------------------------------------------------------------------------
1 | package %PACKAGE%.ios;
2 |
3 | import java.io.File;
4 | import java.io.FileInputStream;
5 | import java.util.Map;
6 | import org.yaml.snakeyaml.Yaml;
7 | import org.robovm.apple.foundation.NSAutoreleasePool;
8 | import org.robovm.apple.foundation.NSBundle;
9 | import org.robovm.apple.uikit.UIApplication;
10 | import org.yaml.snakeyaml.Yaml;
11 | import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
12 | import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
13 | import yae.YaeVM;
14 |
15 | public class IOSLauncher extends IOSApplication.Delegate {
16 | @SuppressWarnings("unchecked")
17 | protected IOSApplication createApplication() {
18 | IOSApplicationConfiguration cfg = new IOSApplicationConfiguration();
19 | cfg.orientationLandscape = true;
20 | cfg.orientationPortrait = true;
21 |
22 | Yaml yaml = new Yaml();
23 | Map config;
24 |
25 | try {
26 | config = (Map)yaml.load(new FileInputStream(new File(NSBundle.getMainBundle().getBundlePath(), "yae/project.yml")));
27 | } catch (Exception e) {
28 | System.err.println(e.getMessage());
29 | System.exit(-1);
30 | return null;
31 | }
32 |
33 | if (config.containsKey("window")) {
34 | Map window = (Map)config.get("window");
35 | if (window.containsKey("orientation")) {
36 | String orientation = (String)window.get("orientation");
37 |
38 | if (orientation.equals("portrait")) {
39 | cfg.orientationLandscape = false;
40 | cfg.orientationPortrait = true;
41 | } else if (orientation.equals("landscape")) {
42 | cfg.orientationLandscape = true;
43 | cfg.orientationPortrait = false;
44 | } else if (orientation.equals("sensor")) {
45 | cfg.orientationLandscape = true;
46 | cfg.orientationPortrait = true;
47 | }
48 | }
49 | }
50 |
51 | return new IOSApplication(new YaeVM(config), cfg);
52 | }
53 |
54 | public static void main(String[] args) {
55 | NSAutoreleasePool pool = new NSAutoreleasePool();
56 | UIApplication.main(args, null, IOSLauncher.class);
57 | pool.close();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/core/platforms/ios/robovm.properties:
--------------------------------------------------------------------------------
1 | app.version=1.0
2 | app.id=%PACKAGE%.ios.IOSLauncher
3 | app.mainclass=%PACKAGE%.ios.IOSLauncher
4 | app.executable=IOSLauncher
5 | app.build=1
6 | app.name=%APP_NAME%
--------------------------------------------------------------------------------
/core/settings.gradle:
--------------------------------------------------------------------------------
1 | include 'shared', 'desktop', 'android', 'ios'
2 |
--------------------------------------------------------------------------------
/core/shared/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "java"
2 |
3 | sourceCompatibility = 1.7
4 | [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
5 |
6 | sourceSets.main.java.srcDirs = [ "src/" ]
7 |
8 | task includeEngineCore(type: Sync) {
9 | from "precompiled"
10 | into "build/classes/main"
11 | }
12 |
13 | task includeLuaSources(type: Sync) {
14 | from "../rocks/share/lua/5.1"
15 | from "../../assets"
16 | into "build/lua"
17 | include "**/*.lua"
18 | }
19 |
20 | task includeMoonSources(type: Sync) {
21 | from "../rocks/share/lua/5.1"
22 | from "../../assets"
23 | into "build/moon"
24 | include "**/*.moon"
25 | }
26 |
27 | task precompile(type: Exec, dependsOn: ["includeEngineCore", "includeMoonSources", "includeLuaSources"]) {
28 | if (System.getProperty('os.name').toLowerCase().contains('windows')) {
29 | commandLine 'cmd', 'precompile.bat'
30 | } else {
31 | commandLine 'sh', 'precompile'
32 | }
33 | }
34 |
35 | compileJava.dependsOn precompile
36 |
--------------------------------------------------------------------------------
/core/shared/precompile:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | cd build/moon
3 | moonc -t ../lua .
4 | cd ../../
5 | java -cp ../libs/bcel.jar:../libs/luaj.jar luajc -r -d build/classes/main build/lua/
6 |
--------------------------------------------------------------------------------
/core/shared/precompile.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | setlocal
3 | cd build\moon
4 | call moonc -t ..\lua .
5 | cd ..\..\
6 | call java -cp ..\libs\bcel.jar;..\libs\luaj.jar luajc -r -d build\classes\main build\lua\
7 | endlocal
8 |
--------------------------------------------------------------------------------
/core/shared/src/yae/Callbacks.java:
--------------------------------------------------------------------------------
1 | package yae;
2 |
3 | import com.badlogic.gdx.Gdx;
4 | import com.badlogic.gdx.Application.ApplicationType;
5 | import org.luaj.vm2.LuaValue;
6 | import org.luaj.vm2.lib.jse.CoerceJavaToLua;
7 |
8 | public class Callbacks {
9 | private YaeVM vm;
10 | private LuaValue root;
11 | private boolean enabled;
12 |
13 | public Callbacks(YaeVM vm) {
14 | this.vm = vm;
15 | }
16 |
17 | public void enable() {
18 | enabled = true;
19 | root = vm.lua.get("yae");
20 | }
21 |
22 | public void load() {
23 | runCallback("load");
24 | }
25 |
26 | public void run() {
27 | runCallback("run");
28 | }
29 |
30 | public void resize(int width, int height) {
31 | runCallback("resize", width, height);
32 | }
33 |
34 | public void visible(boolean isVisible) {
35 | runCallback("visible", isVisible);
36 | }
37 |
38 | public void quit() {
39 | runCallback("_quit");
40 | }
41 |
42 | public void keypressed(int keycode) {
43 | runCallback("_keypressed", keycode);
44 | }
45 |
46 | public void keyreleased(int keycode) {
47 | runCallback("_keyreleased", keycode);
48 | }
49 |
50 | public void textinput(String character) {
51 | runCallback("textinput", character);
52 | }
53 |
54 | public void touchpressed(int x, int y, int pointer) {
55 | runCallback("touchpressed", x, y, pointer);
56 | }
57 |
58 | public void mousepressed(int x, int y, int buttoncode) {
59 | runCallback("_mousepressed", x, y, buttoncode);
60 | }
61 |
62 | public void touchreleased(int x, int y, int pointer) {
63 | runCallback("touchreleased", x, y, pointer);
64 | }
65 |
66 | public void mousereleased(int x, int y, int buttoncode) {
67 | runCallback("_mousereleased", x, y, buttoncode);
68 | }
69 |
70 | public void touchmoved(int x, int y, int pointer) {
71 | runCallback("touchmoved", x, y, pointer);
72 | }
73 |
74 | public void mousemoved(int x, int y) {
75 | runCallback("mousemoved", x, y);
76 | }
77 |
78 | public void mousescrolled(int amount) {
79 | runCallback("mousescrolled", amount);
80 | }
81 |
82 | private void runCallback(String name, Object... args) {
83 | if (!enabled) return;
84 | if (vm.lua == null) return;
85 |
86 | LuaValue callback = root.get(name);
87 | if (!callback.isfunction()) return;
88 |
89 | switch (args.length) {
90 | case 0: callback.call(); break;
91 | case 1: callback.call(CoerceJavaToLua.coerce(args[0])); break;
92 | case 2: callback.call(CoerceJavaToLua.coerce(args[0]), CoerceJavaToLua.coerce(args[1])); break;
93 | case 3: callback.call(CoerceJavaToLua.coerce(args[0]), CoerceJavaToLua.coerce(args[1]), CoerceJavaToLua.coerce(args[2])); break;
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/core/shared/src/yae/Helpers.java:
--------------------------------------------------------------------------------
1 | package yae;
2 |
3 | import java.lang.reflect.Field;
4 | import com.badlogic.gdx.Gdx;
5 | import com.badlogic.gdx.Application.ApplicationType;
6 | import com.badlogic.gdx.files.FileHandle;
7 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
8 | import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
9 |
10 |
11 | public class Helpers {
12 | private boolean runningOnOuya;
13 |
14 | public Helpers() {
15 | try {
16 | Field field = Class.forName("android.os.Build").getDeclaredField("DEVICE");
17 | Object device = field.get(null);
18 | runningOnOuya = "ouya_1_1".equals(device) || "cardhu".equals(device);
19 | } catch (Exception e) { }
20 | }
21 |
22 | public FileHandle localfile(String name) {
23 | return Gdx.files.local(name);
24 | }
25 |
26 | public String getOS() {
27 | String name = "unknown";
28 |
29 | if (Gdx.app.getType() == ApplicationType.Desktop) {
30 | String osname = System.getProperty("os.name").toLowerCase();
31 |
32 | if (osname.startsWith("windows")) {
33 | name = "Windows";
34 | } else if (osname.startsWith("linux")) {
35 | name = "Linux";
36 | } else if (osname.startsWith("mac") || osname.startsWith("darwin")) {
37 | name = "OS X";
38 | } else if (osname.startsWith("sunos")) {
39 | name = "Solaris";
40 | }
41 | } else if (Gdx.app.getType() == ApplicationType.Android) {
42 | name = "Android";
43 | } else if (Gdx.app.getType() == ApplicationType.iOS) {
44 | name = "iOS";
45 | } else if (runningOnOuya) {
46 | name = "Ouya";
47 | }
48 |
49 | return name;
50 | }
51 |
52 | public void endBatch(SpriteBatch batch) {
53 | batch.end();
54 | }
55 |
56 | public void endShapes(ShapeRenderer shapes) {
57 | shapes.end();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/core/shared/src/yae/LoadingScreen.java:
--------------------------------------------------------------------------------
1 | package yae;
2 |
3 | import com.badlogic.gdx.Gdx;
4 | import com.badlogic.gdx.graphics.Color;
5 | import com.badlogic.gdx.graphics.GL20;
6 | import com.badlogic.gdx.graphics.Texture;
7 | import com.badlogic.gdx.graphics.g2d.GlyphLayout;
8 | import com.badlogic.gdx.graphics.g2d.Sprite;
9 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
10 | import com.badlogic.gdx.graphics.g2d.BitmapFont;
11 | import com.badlogic.gdx.graphics.Texture.TextureFilter;
12 | import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
13 | import com.badlogic.gdx.math.Vector2;
14 | import com.badlogic.gdx.utils.Disposable;
15 |
16 |
17 | @SuppressWarnings("deprecation")
18 | public class LoadingScreen implements Disposable {
19 | private final SpriteBatch batch;
20 | private final BitmapFont font;
21 | private final Sprite icon;
22 | private final GlyphLayout glyphs = new GlyphLayout();
23 | private final Color color;
24 | private String text = "";
25 |
26 | public LoadingScreen() {
27 | batch = new SpriteBatch();
28 | font = new FreeTypeFontGenerator(Gdx.files.internal("yae/font.ttf")).generateFont(16);
29 | font.getRegion(0).getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
30 |
31 | Texture iconTex = new Texture(Gdx.files.internal("yae/icon.png"));
32 |
33 | if (!iconTex.getTextureData().isPrepared()) {
34 | iconTex.getTextureData().prepare();
35 | }
36 |
37 | color = new Color(iconTex.getTextureData().consumePixmap().getPixel(0, 0));
38 | icon = new Sprite(iconTex);
39 | icon.setOrigin(0, 0);
40 | }
41 |
42 | public void render () {
43 | Gdx.gl.glClearColor(color.r, color.g, color.b, 1);
44 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
45 | batch.begin();
46 | icon.draw(batch);
47 | font.draw(batch, text,
48 | (Gdx.graphics.getWidth() - glyphs.width) / 2,
49 | (Gdx.graphics.getHeight() - icon.getHeight()) / 2);
50 | batch.end();
51 | }
52 |
53 | public void resize(int width, int height) {
54 | batch.setProjectionMatrix(batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height));
55 | icon.setPosition((width - icon.getWidth()) / 2, (height - icon.getHeight()) / 2);
56 | }
57 |
58 | public void setText(String text) {
59 | this.text = text;
60 | glyphs.setText(font, text);
61 | }
62 |
63 | @Override
64 | public void dispose() {
65 | batch.dispose();
66 | font.dispose();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/core/shared/src/yae/YaeVM.java:
--------------------------------------------------------------------------------
1 | package yae;
2 |
3 | import java.io.InputStream;
4 | import java.io.BufferedReader;
5 | import java.io.IOException;
6 | import java.io.InputStreamReader;
7 | import java.util.HashSet;
8 | import java.util.Map;
9 | import java.util.Set;
10 |
11 | import com.badlogic.gdx.Gdx;
12 | import com.badlogic.gdx.Application.ApplicationType;
13 | import com.badlogic.gdx.ApplicationListener;
14 | import com.badlogic.gdx.InputProcessor;
15 | import com.badlogic.gdx.Input.Keys;
16 | import com.badlogic.gdx.files.FileHandle;
17 | import com.badlogic.gdx.utils.Disposable;
18 |
19 | import org.luaj.vm2.Globals;
20 | import org.luaj.vm2.Lua;
21 | import org.luaj.vm2.LuaError;
22 | import org.luaj.vm2.LuaTable;
23 | import org.luaj.vm2.LuaValue;
24 | import org.luaj.vm2.Varargs;
25 | import org.luaj.vm2.lib.ResourceFinder;
26 | import org.luaj.vm2.lib.VarArgFunction;
27 | import org.luaj.vm2.lib.jse.JsePlatform;
28 | import org.luaj.vm2.lib.jse.CoerceJavaToLua;
29 |
30 | public class YaeVM implements ApplicationListener, InputProcessor, ResourceFinder {
31 | public static final String TAG = "YaeVM";
32 | public static final String VERSION = "v0.7.0";
33 | public static final Helpers util = new Helpers();
34 | public static Globals lua;
35 |
36 | private final Callbacks callbacks = new Callbacks(this);
37 | private LoadingScreen loading;
38 | private boolean ready;
39 | private int state;
40 | private Map config;
41 |
42 | public YaeVM(Map config) {
43 | this.config = config;
44 | }
45 |
46 | @Override
47 | public void create () {
48 | loading = new LoadingScreen();
49 | loading.setText("Starting the engine");
50 | }
51 |
52 | @Override
53 | public void render() {
54 | if (ready) {
55 | callbacks.run();
56 | return;
57 | }
58 |
59 | if (initialize()) {
60 | if (Gdx.input.isTouched()) {
61 | ready = true;
62 | loading.dispose();
63 | callbacks.enable();
64 | callbacks.load();
65 | callbacks.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
66 | return;
67 | }
68 | }
69 |
70 | loading.render();
71 | }
72 |
73 | @Override
74 | public void resize(int width, int height) {
75 | callbacks.resize(width, height);
76 | if (!ready) loading.resize(width, height);
77 | }
78 |
79 | @Override
80 | public void pause() {
81 | callbacks.visible(false);
82 | }
83 |
84 | @Override
85 | public void resume() {
86 | callbacks.visible(true);
87 | }
88 |
89 | @Override
90 | public void dispose() {
91 | callbacks.quit();
92 | if (!ready) loading.dispose();
93 | if (Gdx.app.getType() == ApplicationType.Android) System.exit(0);
94 | }
95 |
96 | @Override
97 | public boolean keyDown(int keycode) {
98 | callbacks.keypressed(keycode);
99 | return false;
100 | }
101 |
102 | @Override
103 | public boolean keyUp(int keycode) {
104 | callbacks.keyreleased(keycode);
105 | return false;
106 | }
107 |
108 | @Override
109 | public boolean keyTyped(char character) {
110 | callbacks.textinput(""+character);
111 | return false;
112 | }
113 |
114 | @Override
115 | public boolean touchDown(int x, int y, int pointer, int buttoncode) {
116 | callbacks.touchpressed(x, y, pointer);
117 | callbacks.mousepressed(x, y, buttoncode);
118 | return false;
119 | }
120 |
121 | @Override
122 | public boolean touchUp(int x, int y, int pointer, int buttoncode) {
123 | callbacks.touchreleased(x, y, pointer);
124 | callbacks.mousereleased(x, y, buttoncode);
125 | return false;
126 | }
127 |
128 | @Override
129 | public boolean touchDragged(int x, int y, int pointer) {
130 | callbacks.touchmoved(x, y, pointer);
131 | return false;
132 | }
133 |
134 | @Override
135 | public boolean mouseMoved(int x, int y) {
136 | callbacks.mousemoved(x, y);
137 | return false;
138 | }
139 |
140 | @Override
141 | public boolean scrolled(int amount) {
142 | callbacks.mousescrolled(amount);
143 | return false;
144 | }
145 |
146 | @Override
147 | public InputStream findResource(String name) {
148 | return Gdx.files.internal(name).read();
149 | }
150 |
151 | private LuaTable convertConfig(Map config) {
152 | LuaTable table = LuaValue.tableOf();
153 |
154 | for (Object entry : config.entrySet()) {
155 | Map.Entry field = (Map.Entry)entry;
156 | String key = field.getKey().toString();
157 | Object value = field.getValue();
158 |
159 | if (field instanceof Map) {
160 | value = convertConfig((Map)value);
161 | }
162 |
163 | table.set(key, CoerceJavaToLua.coerce(value));
164 | }
165 |
166 | return table;
167 | }
168 |
169 | private boolean initialize() {
170 | if (state > 2) return true;
171 |
172 | switch (state) {
173 | case 1:
174 | lua = JsePlatform.standardGlobals();
175 | lua.get("package").set("path", "?.lua;?/init.lua");
176 | lua.set("yae", LuaValue.tableOf());
177 | lua.get("yae").set("project", convertConfig(config));
178 |
179 | lua.set("print", new VarArgFunction() { @Override public LuaValue invoke(Varargs args) {
180 | StringBuffer s = new StringBuffer();
181 |
182 | for (int i = 1; i <= args.narg(); i++) {
183 | if (i > 1) s.append("\t");
184 | s.append(args.arg(i).toString());
185 | }
186 |
187 | Gdx.app.log(TAG, s.toString());
188 | return LuaValue.NONE;
189 | }});
190 |
191 | lua.set("write", new VarArgFunction() { @Override public LuaValue invoke(Varargs args) {
192 | StringBuffer s = new StringBuffer();
193 |
194 | for (int i = 1; i <= args.narg(); i++) {
195 | if (i > 1) s.append("\t");
196 | s.append(args.arg(i).toString());
197 | }
198 |
199 | System.out.print(s.toString());
200 | return LuaValue.NONE;
201 | }});
202 |
203 | lua.set("read", new VarArgFunction() { @Override public LuaValue invoke(Varargs args) {
204 | try {
205 | BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
206 | return LuaValue.valueOf(reader.readLine());
207 | } catch(IOException e) {
208 | return LuaValue.NONE;
209 | }
210 | }});
211 |
212 | loading.setText("Initializing the game");
213 | break;
214 | case 2:
215 | lua.get("require").call("yae");
216 | Gdx.input.setInputProcessor(this);
217 | loading.setText("Touch screen to continue");
218 | break;
219 | }
220 |
221 | state++;
222 | return false;
223 | }
224 | }
225 |
--------------------------------------------------------------------------------
/doc/config.ld:
--------------------------------------------------------------------------------
1 | project = "Yae"
2 | title = "Yae documentation"
3 | description = [[
4 | Game engine for MoonScript, in MoonScript
5 | Open Source. Windows, Mac OS X, Linux, Android, iOS and Ouya.
6 | ]]
7 | format = "markdown"
8 | dir = "build"
9 | style = true
10 |
11 | readme = '../README.md'
12 |
13 | file = {
14 | '../src/yae/accelerometer.moon',
15 | '../src/yae/audio.moon',
16 | '../src/yae/compass.moon',
17 | '../src/yae/console.moon',
18 | '../src/yae/filesystem.moon',
19 | '../src/yae/graphics.moon',
20 | '../src/yae/java.moon',
21 | '../src/yae/keyboard.moon',
22 | '../src/yae/mouse.moon',
23 | '../src/yae/system.moon',
24 | '../src/yae/timer.moon',
25 | '../src/yae/touch.moon',
26 | '../src/yae/window.moon',
27 | '../src/yae/objects/File.moon',
28 | '../src/yae/objects/Font.moon',
29 | '../src/yae/objects/Image.moon',
30 | '../src/yae/objects/Quad.moon',
31 | '../src/yae/objects/Source.moon'
32 | }
33 |
34 | examples = {
35 | '../src/yae/constants/aligns.moon',
36 | '../src/yae/constants/blendmodes.moon',
37 | '../src/yae/constants/buttons.moon',
38 | '../src/yae/constants/filters.moon',
39 | '../src/yae/constants/formats.moon',
40 | '../src/yae/constants/keys.moon',
41 | '../src/yae/constants/shapetypes.moon',
42 | '../src/yae/constants/wraps.moon'
43 | }
44 |
--------------------------------------------------------------------------------
/doc/ldoc.css:
--------------------------------------------------------------------------------
1 | @import url("https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,400,300,700");
2 |
3 | /* BEGIN RESET
4 |
5 | Copyright (c) 2010, Yahoo! Inc. All rights reserved.
6 | Code licensed under the BSD License:
7 | http://developer.yahoo.com/yui/license.html
8 | version: 2.8.2r1
9 | */
10 | html {
11 | color: #000;
12 | background: #FFF;
13 | }
14 |
15 | body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td {
16 | margin: 0;
17 | padding: 0;
18 | }
19 | table {
20 | border-collapse: collapse;
21 | border-spacing: 0;
22 | }
23 | fieldset,img {
24 | border: 0;
25 | }
26 | address,caption,cite,code,dfn,em,strong,th,var,optgroup {
27 | font-style: inherit;
28 | font-weight: inherit;
29 | }
30 | del,ins {
31 | text-decoration: none;
32 | }
33 | li {
34 | list-style: disc;
35 | margin-left: 20px;
36 | }
37 | caption,th {
38 | text-align: left;
39 | }
40 | h1,h2,h3,h4,h5,h6 {
41 | font-size: 100%;
42 | font-weight: bold;
43 | }
44 | q:before,q:after {
45 | content: '';
46 | }
47 | abbr,acronym {
48 | border: 0;
49 | font-variant: normal;
50 | }
51 | sup {
52 | vertical-align: baseline;
53 | }
54 | sub {
55 | vertical-align: baseline;
56 | }
57 | legend {
58 | color: #000;
59 | }
60 | input,button,textarea,select,optgroup,option {
61 | font-family: inherit;
62 | font-size: inherit;
63 | font-style: inherit;
64 | font-weight: inherit;
65 | }
66 | input,button,textarea,select {*font-size:100%;
67 | }
68 | /* END RESET */
69 |
70 | body {
71 | margin-left: 1em;
72 | margin-right: 1em;
73 | font-family: "Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
74 | background-color: #ffffff; margin: 0px;
75 | }
76 |
77 | code, tt { font-family: monospace; font-size: 1.1em; }
78 | span.parameter { font-family:monospace; }
79 | span.parameter:after { content:":"; }
80 | span.types:before { content:"("; }
81 | span.types:after { content:")"; }
82 | .type { font-weight: bold; font-style:italic }
83 |
84 | body, p, td, th { font-size: .95em; line-height: 1.2em;}
85 |
86 | p, ul { margin: 10px 0 0 0px;}
87 |
88 | strong { font-weight: bold;}
89 |
90 | em { font-style: italic;}
91 |
92 | h1, h2, h3, h4 { margin: 15px 0 10px 0; }
93 | h2 { font-size: 1.25em; }
94 | h3 { font-size: 1.15em; }
95 | h4 { font-size: 1.06em; }
96 |
97 | a:link { font-weight: normal; color: #008CBA; text-decoration: none; }
98 | a:visited { font-weight: normal; color: #008CBA; text-decoration: none; }
99 | a:link:hover { text-decoration: underline; }
100 |
101 | hr {
102 | color:#cccccc;
103 | background: #00007f;
104 | height: 1px;
105 | }
106 |
107 | blockquote { margin-left: 3em; }
108 |
109 | ul { list-style-type: disc; }
110 |
111 | p.name {
112 | font-family: "Andale Mono", monospace;
113 | padding-top: 1em;
114 | }
115 |
116 | pre.example {
117 | background-color: rgb(245, 245, 245);
118 | border: 1px solid silver;
119 | padding: 10px;
120 | margin: 10px 0 10px 0;
121 | font-family: "Andale Mono", monospace;
122 | font-size: .85em;
123 | }
124 |
125 | pre {
126 | background-color: rgb(245, 245, 245);
127 | border: 1px solid silver;
128 | padding: 10px;
129 | margin: 10px 0 10px 0;
130 | overflow: auto;
131 | font-family: "Andale Mono", monospace;
132 | }
133 |
134 |
135 | table.index { border: 1px #00007f; }
136 | table.index td { text-align: left; vertical-align: top; }
137 |
138 | #container {
139 | background-color: #f0f0f0;
140 | }
141 |
142 | #product {
143 | text-align: center;
144 | background-color: #ffffff;
145 | }
146 |
147 | #product big {
148 | font-size: 2em;
149 | }
150 |
151 | #main {
152 | background: #333
153 | }
154 |
155 | #navigation {
156 | float: left;
157 | width: 14em;
158 | vertical-align: top;
159 | overflow: visible;
160 | color: white;
161 | background: #333;
162 | }
163 |
164 | #navigation h1 {
165 | padding-left:0.4em;
166 | }
167 |
168 | #navigation h2 {
169 | font-size:1.1em;
170 | padding:0.2em;
171 | }
172 |
173 | #navigation ul
174 | {
175 | font-size:1em;
176 | list-style-type: none;
177 | margin: 1px 1px 10px 1px;
178 | }
179 |
180 | #navigation li {
181 | text-indent: -1em;
182 | display: block;
183 | margin: 3px 0px 0px 22px;
184 | }
185 |
186 | #navigation li li a {
187 | margin: 0px 3px 0px -1em;
188 | }
189 |
190 | #content {
191 | margin-left: 14em;
192 | padding: 1em;
193 | background-color: #fff;
194 | }
195 |
196 | #about {
197 | clear: both;
198 | padding: 5px;
199 | background: transparent;
200 | }
201 |
202 | @media print {
203 | body {
204 | font: 12pt "Times New Roman", "TimeNR", Times, serif;
205 | }
206 | a { font-weight: bold; color: #004080; text-decoration: underline; }
207 |
208 | #main {
209 | background-color: #ffffff;
210 | border-left: 0px;
211 | }
212 |
213 | #container {
214 | margin-left: 2%;
215 | margin-right: 2%;
216 | background-color: #ffffff;
217 | }
218 |
219 | #content {
220 | padding: 1em;
221 | background-color: #ffffff;
222 | }
223 |
224 | #navigation {
225 | display: none;
226 | }
227 | pre.example {
228 | font-family: "Andale Mono", monospace;
229 | font-size: 10pt;
230 | page-break-inside: avoid;
231 | }
232 | }
233 |
234 | table.module_list {
235 | border-width: 1px;
236 | border-style: solid;
237 | border-color: #cccccc;
238 | border-collapse: collapse;
239 | }
240 | table.module_list td {
241 | border-width: 1px;
242 | padding: 3px;
243 | border-style: solid;
244 | border-color: #cccccc;
245 | }
246 | table.module_list td.name { background-color: #f0f0f0; min-width: 200px; }
247 | table.module_list td.summary { width: 100%; }
248 |
249 |
250 | table.function_list {
251 | border-width: 1px;
252 | border-style: solid;
253 | border-color: #cccccc;
254 | border-collapse: collapse;
255 | }
256 | table.function_list td {
257 | border-width: 1px;
258 | padding: 3px;
259 | border-style: solid;
260 | border-color: #cccccc;
261 | }
262 | table.function_list td.name { background-color: #f0f0f0; min-width: 200px; }
263 | table.function_list td.summary { width: 100%; }
264 |
265 | ul.nowrap {
266 | overflow:auto;
267 | white-space:nowrap;
268 | }
269 |
270 | dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;}
271 | dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;}
272 | dl.table h3, dl.function h3 {font-size: .95em;}
273 |
274 | /* stop sublists from having initial vertical space */
275 | ul ul { margin-top: 0px; }
276 | ol ul { margin-top: 0px; }
277 | ol ol { margin-top: 0px; }
278 | ul ol { margin-top: 0px; }
279 |
280 | /* make the target distinct; helps when we're navigating to a function */
281 | a:target + * {
282 | background-color: #FF9;
283 | }
284 |
285 | /* styles for prettification of source */
286 | pre .comment { color: #558817; }
287 | pre .constant { color: #a8660d; }
288 | pre .escape { color: #844631; }
289 | pre .keyword { color: #aa5050; font-weight: bold; }
290 | pre .library { color: #0e7c6b; }
291 | pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
292 | pre .string { color: #8080ff; }
293 | pre .number { color: #f8660d; }
294 | pre .operator { color: #2239a8; font-weight: bold; }
295 | pre .preprocessor, pre .prepro { color: #a33243; }
296 | pre .global { color: #800080; }
297 | pre .prompt { color: #558817; }
298 | pre .url { color: #272fc2; text-decoration: underline; }
--------------------------------------------------------------------------------
/res/.gitignore:
--------------------------------------------------------------------------------
1 | ## Yae
2 | .yae
3 | build/
4 |
5 | ## OS Specific
6 | .DS_Store
7 | Thumbs.db
8 |
--------------------------------------------------------------------------------
/res/font.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/res/font.ttf
--------------------------------------------------------------------------------
/res/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deathbeam/yae/aa227ddffd340a18f875fed215eb95c9a98094e3/res/icon.png
--------------------------------------------------------------------------------
/res/main.moon:
--------------------------------------------------------------------------------
1 | -- Use with for easier usage and prettier code
2 | with yae
3 | .draw = ->
4 | -- Draw the text on specified coordinates
5 | .graphics.print "This is #{.project.name}", 10, 10
6 |
7 | .keypressed = (key) ->
8 | -- Quit application if Q or Escape key was pressed
9 | if key == "q" or key == "escape"
10 | .system.quit!
11 |
--------------------------------------------------------------------------------
/src/yae.moon:
--------------------------------------------------------------------------------
1 | -- Easy type checking for MoonScript classes
2 | oldType = type
3 | export type = (value) ->
4 | baseType = oldType value
5 | if base_type == "table"
6 | cls = value.__class
7 | return cls.__name if cls
8 | baseType
9 |
10 | -- Initialize java and console module first
11 | yae.console = require "yae.console"
12 | yae.java = require "yae.java"
13 |
14 | -- Initialize the objects
15 | yae.File = require "yae.objects.File"
16 | yae.Font = require "yae.objects.Font"
17 | yae.Image = require "yae.objects.Image"
18 | yae.Quad = require "yae.objects.Quad"
19 | yae.Source = require "yae.objects.Source"
20 |
21 | -- Initialize the modules
22 | yae.accelerometer = require "yae.accelerometer"
23 | yae.audio = require "yae.audio"
24 | yae.compass = require "yae.compass"
25 | yae.filesystem = require "yae.filesystem"
26 | yae.graphics = require "yae.graphics"
27 | yae.keyboard = require "yae.keyboard"
28 | yae.mouse = require "yae.mouse"
29 | yae.system = require "yae.system"
30 | yae.timer = require "yae.timer"
31 | yae.touch = require "yae.touch"
32 | yae.window = require "yae.window"
33 |
34 | -- Wrap the callbacks to be usefull for the engine
35 | Constants = require "yae.constants"
36 | import keycodes, buttoncodes from Constants
37 |
38 | yae._keypressed = (keycode) ->
39 | yae.keypressed(keycodes[keycode]) if yae.keypressed
40 |
41 | yae._keyreleased = (keycode) ->
42 | yae.keyreleased(keycodes[keycode]) if yae.keyreleased
43 |
44 | yae._mousepressed = (x, y, buttoncode) ->
45 | yae.mousepressed(buttoncodes[buttoncode]) if yae.mousepressed
46 |
47 | yae._mousereleased = (x, y, buttoncode) ->
48 | yae.mousereleased(buttoncodes[buttoncode]) if yae.mousereleased
49 |
50 | yae._quit = ->
51 | if yae.quit then yae.quit!
52 | yae.audio.stopAll!
53 |
54 | -- Main loop function
55 | yae.run = ->
56 | dt = yae.timer.getDelta!
57 | yae.update(dt) if yae.update
58 | yae.graphics.clear!
59 | yae.graphics.origin!
60 | yae.draw! if yae.draw
61 | yae.graphics.present!
62 |
63 | require "main"
64 |
--------------------------------------------------------------------------------
/src/yae/accelerometer.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- User input from accelerometer (works only on mobile devices).
3 | -------------------------------------------------------------------------------
4 | -- An accelerometer measures the acceleration of a device on three axes. From
5 | -- this acceleration one can derive the tilt or orientation of the device.
6 | --
7 | -- Acceleration is measured in meters per second per second (m/s²). If an axis
8 | -- is pointing straight towards the center of the earth, its acceleration will
9 | -- be roughly -10 m/s². If it is pointing in the opposite direction, the
10 | -- acceleration will be 10 m/s².
11 | --
12 | -- @module yae.accelerometer
13 |
14 | import java from yae
15 | Gdx = java.require "com.badlogic.gdx.Gdx"
16 | Peripheral = java.require "com.badlogic.gdx.Input$Peripheral"
17 |
18 | ---
19 | -- Get current X relative to the center of earth
20 | -- @treturn number x value of accelerometer
21 | -- @usage
22 | -- x = yae.accelerometer.getX!
23 | getX = ->
24 | Gdx.input\getAccelerometerX!
25 |
26 | ---
27 | -- Get current Y relative to the center of earth
28 | -- @treturn number y value of accelerometer
29 | -- @usage
30 | -- y = yae.accelerometer.getY!
31 | getY = ->
32 | Gdx.input\getAccelerometerY!
33 |
34 | ---
35 | -- Get current Z relative to the center of earth
36 | -- @treturn number z value of accelerometer
37 | -- @usage
38 | -- z = yae.accelerometer.getZ!
39 | getZ = ->
40 | Gdx.input\getAccelerometerZ!
41 |
42 | ---
43 | -- Get current X, Y and Z relative to the center of earth
44 | -- @treturn number x value of accelerometer
45 | -- @treturn number y value of accelerometer
46 | -- @treturn number z value of accelerometer
47 | -- @usage
48 | -- x, y, z = yae.accelerometer.getRotation!
49 | getRotation = ->
50 | getX!, getY!, getZ!
51 |
52 | ---
53 | -- Checks if accelerometer is available on current device
54 | -- @treturn bool True if accelerometer is available
55 | -- @usage
56 | -- available = yae.accelerometer.isAvailable!
57 | isAvailable = ->
58 | Gdx.input\isPeripheralAvailable Peripheral.Accelerometer
59 |
60 | {
61 | :getX
62 | :getY
63 | :getZ
64 | :getRotation
65 | :isAvailable
66 | }
67 |
--------------------------------------------------------------------------------
/src/yae/audio.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- Handles creating, playing and manipulating sound and music instances.
3 | -------------------------------------------------------------------------------
4 | -- Sound effects are small audio samples, usually no longer than a few seconds,
5 | -- that are played back on specific game events such as a character jumping or
6 | -- shooting a gun.
7 | -- For any sound that's longer than a few seconds it is preferable to stream it
8 | -- from disk instead of fully loading it into RAM. Yae provides a "stream"
9 | -- source that lets you do that.
10 | --
11 | -- Yae supports MP3, OGG and WAV files.
12 | -- ***note1:*** iOS currently does not support OGG files.
13 | -- ***note2:*** On Android, a static source cannot be over 1 MB
14 | --
15 | -- @module yae.audio
16 |
17 | import Source from yae
18 |
19 | sources = {}
20 | globalvolume = 1
21 |
22 | ---
23 | -- Gets the current number of simultaneously playing sources.
24 | -- @treturn number The current number of simultaneously playing sources.
25 | -- @usage
26 | -- numSources = yae.audio.getSourcesCount!
27 | getSourceCount = ->
28 | #sources
29 |
30 |
31 | ---
32 | -- Returns the master volume.
33 | -- @treturn number The current master volume
34 | -- @usage
35 | -- volume = yae.audio.getVolume!
36 | getVolume = ->
37 | globalvolume
38 |
39 | ---
40 | -- Creates a new Source from a filepath.
41 | -- @string filename The name (and path) of the file.
42 | -- @string[opt="stream"] audiotype Type of the audio.
43 | -- @string[opt="internal"] filetype Type of the file
44 | -- @treturn Source A new Source that can play the specified audio.
45 | -- @see yae.Source.new
46 | -- @usage
47 | -- source = yae.audio.newSource filename, audiotype, filetype
48 | newSource = (filename, audiotype, filetype) ->
49 | source = Source(filename, audiotype, filetype)
50 | table.insert sources, source
51 | return source
52 |
53 | ---
54 | -- Pause the specified Source.
55 | -- @tparam Source source The Source on which to pause the playback
56 | -- @usage
57 | -- yae.audio.pause source
58 | pause = (source) ->
59 | source\pause!
60 |
61 | ---
62 | -- Plays the specified Source.
63 | -- @tparam Source source The Source to play.
64 | -- @usage
65 | -- yae.audio.play source
66 | play = (source) ->
67 | source\setVolume globalvolume
68 | source\play!
69 |
70 | ---
71 | -- Resumes the specified paused Source.
72 | -- @tparam Source source The Source to resume
73 | -- @usage
74 | -- yae.audio.resume source
75 | resume = (source) ->
76 | source\resume!
77 |
78 | ---
79 | -- Sets the master volume.
80 | -- @tparam number volume 1.0 is max and 0.0 is off.
81 | -- @usage
82 | -- yae.audio.setVolume volume
83 | setVolume = (volume) ->
84 | globalvolume = volume
85 |
86 | for i, source in ipairs sources
87 | source\setVolume globalvolume
88 |
89 | ---
90 | -- This function will only stop the specified Source.
91 | -- @tparam Source source The Source on which to stop the playback.
92 | -- @usage
93 | -- yae.audio.stop source
94 | stop = (source) ->
95 | source\stop!
96 |
97 | ---
98 | -- This function will stop all currently active sources.
99 | -- @usage
100 | -- yae.audio.stopAll!
101 | stopAll = ->
102 | for i, source in ipairs sources
103 | source\stop!
104 | source\free!
105 |
106 | {
107 | :getSourceCount
108 | :getVolume
109 | :newSource
110 | :pause
111 | :play
112 | :resume
113 | :setVolume
114 | :stop
115 | :stopAll
116 | }
117 |
--------------------------------------------------------------------------------
/src/yae/compass.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- User input from compass (works only on mobile devices).
3 | -------------------------------------------------------------------------------
4 | -- Some Android devices and iOS devices have an integrated magnetic field
5 | -- sensor that provides information on how the device is oriented with respect
6 | -- to the magnetic north pole.
7 | --
8 | -- ***Note =*** The compass is currently not available on iOS devices since
9 | -- there is no implementation in the RoboVM - backend yet.
10 | --
11 | -- @module yae.compass
12 |
13 | import java from yae
14 | Gdx = java.require "com.badlogic.gdx.Gdx"
15 |
16 | ---
17 | -- Get the angle of the device's orientation around the z-axis. The positive
18 | -- z-axis points towards the earths center
19 | -- @treturn number azimuth
20 | -- @usage
21 | -- azimuth = yae.compass.getAzimuth!
22 | getAzimuth = ->
23 | Gdx.input\getAzimuth!
24 |
25 | ---
26 | -- Get the angle of the device's orientation around the x-axis. The positive
27 | -- x-axis roughly points to the west and is orthogonal to the z- and y-axis
28 | -- @treturn number pitch
29 | -- @usage
30 | -- pitch = yae.compass.getPitch!
31 | getPitch = ->
32 | Gdx.input\getPitch!
33 |
34 | ---
35 | -- Get the angle of the device's orientation around the y-axis. The positive
36 | -- y-axis points toward the magnetic north pole of the earth while remaining
37 | -- orthogonal to the other two axes.
38 | -- @treturn number roll
39 | -- @usage
40 | -- roll = yae.compass.getRoll!
41 | getRoll = ->
42 | Gdx.input\getRoll!
43 |
44 | ---
45 | -- Get current compass azimuth, pitch and roll
46 | -- @treturn number azimuth
47 | -- @treturn number pitch
48 | -- @treturn number roll
49 | -- @usage
50 | -- azimuth, pitch, roll = yae.compass.getOrientation!
51 | getOrientation = ->
52 | getAzimuth!, getPitch!, getRoll!
53 |
54 | ---
55 | -- Checks if compass is available on current device
56 | -- @treturn bool True if compass is available
57 | -- @usage
58 | -- available = yae.compass.isAvailable!
59 | isAvailable = ->
60 | Gdx.input\isPeripheralAvailable Peripheral.Compass
61 |
62 | {
63 | :getAzimuth
64 | :getPitch
65 | :getRoll
66 | :getOrientation
67 | :isAvailable
68 | }
69 |
--------------------------------------------------------------------------------
/src/yae/console.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- Handles input and output to console.
3 | -------------------------------------------------------------------------------
4 | -- @module yae.console
5 |
6 | ---
7 | -- Write text to console
8 | -- @param ... text to write
9 | -- @usage
10 | -- yae.console.write "Hello", "World"
11 | write = write
12 |
13 | ---
14 | -- Read text from console
15 | -- @treturn string entered text
16 | -- @usage
17 | -- message = yae.console.read!
18 | -- print message
19 | read = read
20 |
21 | {
22 | :read
23 | :write
24 | }
--------------------------------------------------------------------------------
/src/yae/constants/aligns.moon:
--------------------------------------------------------------------------------
1 | Align = yae.java.require "com.badlogic.gdx.utils.Align"
2 |
3 | {
4 | "center": Align.center
5 | "top": Align.top
6 | "bottom": Align.bottom
7 | "left": Align.left
8 | "right": Align.right
9 | "topleft": Align.topLeft
10 | "topright": Align.topRight
11 | "bottomleft": Align.bottomLeft
12 | "bottomright": Align.bottomRight
13 | }
14 |
--------------------------------------------------------------------------------
/src/yae/constants/blendmodes.moon:
--------------------------------------------------------------------------------
1 | GL20 = yae.java.require "com.badlogic.gdx.graphics.GL20"
2 |
3 | {
4 | "alpha": { GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA }
5 | "multiplicative": { GL20.GL_DST_COLOR, GL20.GL_ZERO }
6 | "premultiplied": { GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA }
7 | "subtractive": { GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_ONE }
8 | "additive": { GL20.GL_SRC_ALPHA, GL20.GL_ONE }
9 | "screen": { GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_COLOR }
10 | "replace": { GL20.GL_ONE, GL20.GL_ZERO }
11 | }
12 |
--------------------------------------------------------------------------------
/src/yae/constants/buttons.moon:
--------------------------------------------------------------------------------
1 | {
2 | "left": 0
3 | "right": 1
4 | "middle": 2
5 | "back": 3
6 | "forward": 4
7 | }
8 |
--------------------------------------------------------------------------------
/src/yae/constants/filters.moon:
--------------------------------------------------------------------------------
1 | TextureFilter = yae.java.require "com.badlogic.gdx.graphics.Texture$TextureFilter"
2 |
3 | {
4 | "linear": TextureFilter.Linear
5 | "nearest": TextureFilter.Nearest
6 | "mipmap": TextureFilter.MipMap
7 | "mipmaplinearlinear": TextureFilter.MipMapLinearLinear
8 | "mipmapnearestnearest": TextureFilter.MipMapNearestNearest
9 | "mipmaplinearnearest": TextureFilter.MipMapLinearNearest
10 | "mipmapnearestlinear": TextureFilter.MipMapNearestLinear
11 | }
12 |
--------------------------------------------------------------------------------
/src/yae/constants/formats.moon:
--------------------------------------------------------------------------------
1 | Format = yae.java.require "com.badlogic.gdx.graphics.Pixmap$Format"
2 |
3 | {
4 | "rgba8": Format.RGBA8888
5 | "rgb8": Format.RGB888
6 | "rgba4": Format.RGBA4444
7 | "rgb565": Format.RGB565
8 | "alpha": Format.Alpha
9 | "intensity": Format.Intensity
10 | "luminancealpha": Format.LuminanceAlpha
11 | }
12 |
--------------------------------------------------------------------------------
/src/yae/constants/init.moon:
--------------------------------------------------------------------------------
1 | buttons = require "yae.constants.buttons"
2 | keys = require "yae.constants.keys"
3 | formats = require "yae.constants.formats"
4 | wraps = require "yae.constants.wraps"
5 | filters = require "yae.constants.filters"
6 | blendmodes = require "yae.constants.blendmodes"
7 | shapetypes = require "yae.constants.shapetypes"
8 | aligns = require "yae.constants.aligns"
9 |
10 | keycodes = {}
11 | for k, v in pairs keys
12 | keycodes[v] = k
13 |
14 | buttoncodes = {}
15 | for k, v in pairs buttons
16 | buttoncodes[v] = k
17 |
18 | formatcodes = {}
19 | for k, v in pairs formats
20 | formatcodes[v] = k
21 |
22 | wrapcodes = {}
23 | for k, v in pairs wraps
24 | wrapcodes[v] = k
25 |
26 | filtercodes = {}
27 | for k, v in pairs filters
28 | filtercodes[v] = k
29 |
30 | {
31 | :keys
32 | :keycodes
33 | :buttons
34 | :buttoncodes
35 | :formats
36 | :formatcodes
37 | :wraps
38 | :wrapcodes
39 | :filters
40 | :filtercodes
41 | :blendmodes
42 | :shapetypes
43 | :aligns
44 | }
45 |
--------------------------------------------------------------------------------
/src/yae/constants/keys.moon:
--------------------------------------------------------------------------------
1 | {
2 | "unknown": -1
3 | -- Alpha-numeric
4 | "0": 7
5 | "1": 8
6 | "2": 9
7 | "3": 10
8 | "4": 11
9 | "5": 12
10 | "6": 13
11 | "7": 14
12 | "8": 15
13 | "9": 16
14 | "a": 29
15 | "b": 30
16 | "c": 31
17 | "d": 32
18 | "e": 33
19 | "f": 34
20 | "g": 35
21 | "h": 36
22 | "i": 37
23 | "j": 38
24 | "k": 39
25 | "l": 40
26 | "m": 41
27 | "n": 42
28 | "o": 43
29 | "p": 44
30 | "q": 45
31 | "r": 46
32 | "s": 47
33 | "t": 48
34 | "u": 49
35 | "v": 50
36 | "w": 51
37 | "x": 52
38 | "y": 53
39 | "z": 54
40 | -- Symbols
41 | "*": 17
42 | "#": 18
43 | ",": 55
44 | ".": 56
45 | "`": 68
46 | "-": 69
47 | "=": 70
48 | "[": 71
49 | "]": 72
50 | "\\": 73
51 | ";": 74
52 | ":": 243
53 | "'": 75
54 | "/": 76
55 | "@": 77
56 | "+": 81
57 | -- Keypad
58 | "kp0": 144
59 | "kp1": 145
60 | "kp2": 146
61 | "kp3": 147
62 | "kp4": 148
63 | "kp5": 149
64 | "kp6": 150
65 | "kp7": 151
66 | "kp8": 152
67 | "kp9": 153
68 | -- Function
69 | "f1": 244
70 | "f2": 245
71 | "f3": 246
72 | "f4": 247
73 | "f5": 248
74 | "f6": 249
75 | "f7": 250
76 | "f8": 251
77 | "f9": 252
78 | "f10": 253
79 | "f11": 254
80 | "f12": 255
81 | -- Navigation
82 | "up": 19
83 | "down": 20
84 | "left": 21
85 | "right": 22
86 | "center": 23
87 | "end": 132
88 | "pageup": 92
89 | "pagedown": 93
90 | -- Command
91 | "insert": 133
92 | "delete": 67
93 | "backspace": 67
94 | -- Gamepad
95 | "btna": 96
96 | "btnb": 97
97 | "btnc": 98
98 | "btnx": 99
99 | "btny": 100
100 | "btnz": 101
101 | "btnl1": 102
102 | "btnr1": 103
103 | "btnl2": 104
104 | "btnr2": 105
105 | "btnthumbl": 106
106 | "btnthumbr": 107
107 | "btnstart": 108
108 | "btnselect": 109
109 | "btnmode": 110
110 | -- D-pad
111 | "dpup": 19
112 | "dpdown": 20
113 | "dpleft": 21
114 | "dpright": 22
115 | "dpcenter": 23
116 | -- Special
117 | "lalt": 57
118 | "ralt": 58
119 | "lshift": 59
120 | "rshift": 60
121 | "tab": 61
122 | "space": 62
123 | "lctrl": 129
124 | "rctrl": 130
125 | "escape": 131
126 | "return": 66
127 | -- Media
128 | "volumeup": 24
129 | "volumedown": 25
130 | "pause": 85
131 | "stop": 86
132 | "next": 87
133 | "prev": 88
134 | "rewind": 89
135 | "fastforward": 90
136 | "mute": 91
137 | -- Other
138 | "sleft": 1
139 | "sright": 2
140 | "home": 3
141 | "back": 4
142 | "call": 5
143 | "endcall": 6
144 | "power": 26
145 | "camera": 27
146 | "menu": 82
147 | "notification": 83
148 | "search": 84
149 | "clear": 28
150 | "sym": 63
151 | "www": 64
152 | "mail": 65
153 | "num": 78
154 | "headsethook": 79
155 | "focus": 80
156 | "pictsymbols": 94
157 | "charset": 95
158 | "forwarddelete": 112
159 | }
160 |
--------------------------------------------------------------------------------
/src/yae/constants/shapetypes.moon:
--------------------------------------------------------------------------------
1 | ShapeType = yae.java.require "com.badlogic.gdx.graphics.glutils.ShapeRenderer$ShapeType"
2 |
3 | {
4 | "line": ShapeType.Line
5 | "fill": ShapeType.Filled
6 | }
7 |
--------------------------------------------------------------------------------
/src/yae/constants/wraps.moon:
--------------------------------------------------------------------------------
1 | TextureWrap = yae.java.require "com.badlogic.gdx.graphics.Texture$TextureWrap"
2 |
3 | {
4 | "mirroredrepeat": TextureWrap.MirroredRepeat
5 | "clamp": TextureWrap.ClampToEdge
6 | "repeat": TextureWrap.Repeat
7 | }
8 |
--------------------------------------------------------------------------------
/src/yae/filesystem.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- Allows manipulation with files and directories.
3 | -------------------------------------------------------------------------------
4 | -- Yae applications run on three different platforms
5 | -- * desktop systems (Windows, Linux, Mac OS X)
6 | -- * Android
7 | -- * and iOS.
8 | --
9 | -- Each of these platforms handles file I/O a little differently.
10 | --
11 | -- Each Yae file has a type which defines where the file is located.
12 | -- The following table illustrates the availability and location of each file
13 | -- type for each platform.
14 | --
15 | -- **Classpath**
16 | -- Classpath files are directly stored in your source folders. These get
17 | -- packaged with your jars and are always *read-only*. They have their purpose,
18 | -- but should be avoided if possible.
19 | --
20 | -- **Internal**
21 | -- Internal files are relative to the application’s *root* or *working*
22 | -- directory on desktops and relative to the *assets* directory on Android.
23 | -- These files are *read-only*. If a file can't be found on the internal storage,
24 | -- the file module falls back to searching the file on the classpath. This file
25 | -- type is default for Yae files.
26 | --
27 | -- **Local**
28 | -- Local files are stored relative to the application's *root* or *working*
29 | -- directory on desktops and relative to the internal (private) storage of the
30 | -- application on Android. Note that Local and internal are mostly the same on the
31 | -- desktop.
32 | --
33 | -- **External**
34 | -- External files paths are relative to the
35 | -- [SD card root](http =//developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory\(\))
36 | -- on Android and to the [home directory](http =//www.roseindia.net/java/beginners/UserHomeExample.shtml)
37 | -- of the current user on desktop systems.
38 | --
39 | -- **Absolute**
40 | -- Absolute files need to have their fully qualified paths specified. For the
41 | -- sake of portability, this option must be used only when absolutely necessary.
42 | --
43 | -- @module yae.filesystem
44 |
45 | import java, File from yae
46 | Gdx = java.require "com.badlogic.gdx.Gdx"
47 | YaeVM = java.require "yae.YaeVM"
48 |
49 | ---
50 | -- Append data to an existing file.
51 | -- @string filename The name (and path) of the file.
52 | -- @string text The string data to append to the file.
53 | -- @string[opt="internal"] filetype Type of the file
54 | -- @usage
55 | -- yae.filesystem.append filename, text, filetype
56 | append = (filename, text, filetype) ->
57 | file = newFile filename, filetype
58 | file\append text
59 |
60 | ---
61 | -- Copy file.
62 | -- @string from_filename The name (and path) of the source file.
63 | -- @string to_filename The name (and path) of the destination file.
64 | -- @string[opt="internal"] from_filetype Type of the source file
65 | -- @string[opt="internal"] to_filetype Type of the destination file
66 | -- @usage
67 | -- yae.filesystem.copy from_filename, to_filename, from_filetype, to_filetype
68 | copy = (from_filename, to_filename, from_filetype, to_filetype) ->
69 | from_file = newFile from_filename, from_filetype
70 | to_file = newFile from_filename, from_filetype
71 | from_file\copy to_file
72 |
73 | ---
74 | -- Creates a directory.
75 | -- @string filename The name (and path) of the file.
76 | -- @string[opt="internal"] filetype Type of the file
77 | -- @usage
78 | -- yae.filesystem.createDirectory filename, filetype
79 | createDirectory = (filename, filetype) ->
80 | file = newFile filename, filetype
81 | file\create_directory!
82 |
83 | ---
84 | -- Check whether a file or directory exists.
85 | -- @string filename The name (and path) of the file.
86 | -- @string[opt="internal"] filetype Type of the file
87 | -- @treturn bool True if there is a file or directory with the specified name.
88 | -- False otherwise.
89 | -- @usage
90 | -- exists = yae.filesystem.exists filename, filetype
91 | exists = (filename, filetype) ->
92 | file = newFile filename, filetype
93 | file\exists!
94 |
95 | ---
96 | -- Returns a table with the names of files and subdirectories in the specified
97 | -- path. The table is not sorted in any way; the order is undefined.
98 | -- @string filename The name (and path) of the file.
99 | -- @string[opt="internal"] filetype Type of the file
100 | -- @treturn table A sequence with the names of all files and subdirectories as
101 | -- strings.
102 | -- @usage
103 | -- items = yae.filesystem.getDirectoryItems filename, filetype
104 | getDirectoryItems = (filename, filetype) ->
105 | file = newFile filename, filetype
106 | file\list!
107 |
108 | ---
109 | -- Get external storage path
110 | -- @treturn string absolute path to external storage location
111 | -- @usage
112 | -- externalPath = yae.filesystem.getExternalPath!
113 | getExternalPath = ->
114 | Gdx.files\getExternalStoragePath!
115 |
116 | ---
117 | -- Get local storage path
118 | -- @treturn string absolute path to local storage location
119 | -- @usage
120 | -- localPath = yae.filesystem.getLocalPath!
121 | getLocalPath = ->
122 | Gdx.files\getLocalStoragePath!
123 |
124 | ---
125 | -- Get path to current directory
126 | -- @treturn string absolute path to current directory
127 | -- @usage
128 | -- workingPath = yae.filesystem.getWorkingPath!
129 | getWorkingPath = ->
130 | file = newFile(".")\file!
131 | file\getAbsolutePath!
132 |
133 | ---
134 | -- Gets the last modification time of a file.
135 | -- @string filename The name (and path) of the file.
136 | -- @string[opt="internal"] filetype Type of the file
137 | -- @treturn number The last modification time in seconds since the unix epoch
138 | -- or nil on failure.
139 | -- @usage
140 | -- lastModified = yae.filesystem.getLastModified filename, filetype
141 | getLastModified = (filename, filetype) ->
142 | file = newFile filename, filetype
143 | file\last_modified!
144 |
145 | ---
146 | -- Gets the size in bytes of a file.
147 | -- @string filename The name (and path) of the file.
148 | -- @string[opt="internal"] filetype Type of the file
149 | -- @treturn number The size in bytes of the file, or nil on failure.
150 | -- @usage
151 | -- size = yae.filesystem.getSize filename, filetype
152 | getSize = (filename, filetype) ->
153 | file = newFile filename, filetype
154 | file\size!
155 |
156 | ---
157 | -- Check whether something is a directory.
158 | -- @string filename The name (and path) of the file.
159 | -- @string[opt="internal"] filetype Type of the file
160 | -- @treturn bool True if there is a directory with the specified name. False
161 | -- otherwise.
162 | -- @usage
163 | -- isDirectory = yae.filesystem.isDirectory filename, filetype
164 | isDirectory = (filename, filetype) ->
165 | file = newFile filename, filetype
166 | file\is_directory!
167 |
168 | ---
169 | -- Check whether something is a file.
170 | -- @string filename The name (and path) of the file.
171 | -- @string[opt="internal"] filetype Type of the file
172 | -- @treturn bool True if there is a file with the specified name. False
173 | -- otherwise.
174 | -- @usage
175 | -- isFile = yae.filesystem.isFile filename, filetype
176 | isFile = (filename, filetype) ->
177 | file = newFile filename, filetype
178 | file\is_file!
179 |
180 | ---
181 | -- Load a lua or moon file (but not run it)
182 | -- @string filename The name (and path) of the file.
183 | -- @string[opt="internal"] filetype Type of the file
184 | -- @treturn function The loaded chunk
185 | -- @usage
186 | -- chunk = yae.filesystem.load filename, filetype
187 | -- result = chunk!
188 | load = (filename, filetype) ->
189 | file = newFile filename, filetype
190 | YaeVM.lua\load file\reader!, filename
191 |
192 |
193 | ---
194 | -- Move file.
195 | -- @string from_filename The name (and path) of the source file.
196 | -- @string to_filename The name (and path) of the destination file.
197 | -- @string[opt="internal"] from_filetype Type of the source file
198 | -- @string[opt="internal"] to_filetype Type of the destination file
199 | -- @usage
200 | -- yae.filesystem.move from_filename, to_filename, from_filetype, to_filetype
201 | move = (from_filename, to_filename, from_filetype, to_filetype) ->
202 | from_file = newFile from_filename, from_filetype
203 | to_file = newFile from_filename, from_filetype
204 | from_file\move to_file
205 | true
206 |
207 | ---
208 | -- Creates a new File object.
209 | -- @string filename The name (and path) of the file.
210 | -- @string[opt="internal"] filetype Type of the file
211 | -- @treturn File The new File object.
212 | newFile = (filename, filetype) ->
213 | File filename, filetype
214 |
215 | ---
216 | -- Read the contents of a file
217 | -- @string filename The name (and path) of the file.
218 | -- @string[opt="internal"] filetype Type of the file
219 | -- @treturn string The file contents
220 | -- @usage
221 | -- contents = yae.filesystem.read filename, filetype
222 | read = (filename, filetype) ->
223 | file = newFile filename, filetype
224 | file\read!
225 |
226 | ---
227 | -- Removes a file or directory.
228 | -- Write data to an existing file.
229 | -- @string filename The name (and path) of the file.
230 | -- @string[opt="internal"] filetype Type of the file
231 | -- @usage
232 | -- yae.filesystem.remove filename, filetype
233 | remove = (filename, filetype) ->
234 | file = newFile filename, filetype
235 | file\remove!
236 | true
237 |
238 | ---
239 | -- Write data to an existing file.
240 | -- @string filename The name (and path) of the file.
241 | -- @string text The string data to write to the file.
242 | -- @string[opt="internal"] filetype Type of the file
243 | -- @usage
244 | -- yae.filesystem.write filename, text, filetype
245 | write = (filename, text, filetype) ->
246 | file = newFile filename, filetype
247 | file\write text
248 | true
249 |
250 | {
251 | :append
252 | :copy
253 | :createDirectory
254 | :exists
255 | :getDirectoryItems
256 | :getExternalPath
257 | :getLocalPath
258 | :getWorkingPath
259 | :getLastModified
260 | :getSize
261 | :newFile
262 | :isDirectory
263 | :isFile
264 | :load
265 | :move
266 | :read
267 | :remove
268 | :write
269 | }
270 |
--------------------------------------------------------------------------------
/src/yae/graphics.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- Provides simple way to load, render and draw things.
3 | -------------------------------------------------------------------------------
4 | -- The primary responsibility for the yae.graphics module is the drawing of
5 | -- lines, shapes, text, Images and other Drawable objects onto the screen. Its
6 | -- secondary responsibilities include loading external files (including Images
7 | -- and Fonts) into memory and managing screen geometry.
8 | -- Yae's coordinate system is rooted in the upper-left corner of the screen,
9 | -- which is at location (0, 0). The x axis is horizontal: larger values are
10 | -- further to the right. The y axis is vertical: larger values are further
11 | -- towards the bottom.
12 | --
13 | -- @module yae.graphics
14 |
15 | import java, Font, Image, Quad from yae
16 | Constants = require "yae.constants"
17 | Color = java.require "com.badlogic.gdx.graphics.Color"
18 | Gdx = java.require "com.badlogic.gdx.Gdx"
19 | GL20 = java.require "com.badlogic.gdx.graphics.GL20"
20 | Matrix4 = java.require "com.badlogic.gdx.math.Matrix4"
21 | YaeVM = java.require "yae.YaeVM"
22 | OrthographicCamera = java.require "com.badlogic.gdx.graphics.OrthographicCamera"
23 | ShapeRender = java.require "com.badlogic.gdx.graphics.glutils.ShapeRenderer"
24 | SpriteBatch = java.require "com.badlogic.gdx.graphics.g2d.SpriteBatch"
25 |
26 | shader = SpriteBatch\createDefaultShader!
27 | batch = java.new SpriteBatch, 1000, shader
28 | shapes = java.new ShapeRender
29 | font = Font!
30 | shapes\setAutoShapeType true
31 | matrix = java.new Matrix4
32 | color = java.new Color, 1, 1, 1, 1
33 | background = java.new Color, 0, 0, 0, 1
34 | blending = "alpha"
35 | batch\setColor color
36 | shapes\setColor color
37 | font.font\setColor color
38 | camera = java.new OrthographicCamera
39 | camera\setToOrtho true
40 | batch\setProjectionMatrix camera.combined
41 | shapes\setProjectionMatrix camera.combined
42 | matrixDirty = false
43 |
44 | check = (textureBased) ->
45 | if textureBased
46 | if matrixDirty
47 | batch\setTransformMatrix matrix
48 | matrixDirty = false
49 |
50 | if shapes\isDrawing! then YaeVM.util\endShapes shapes
51 | if not batch\isDrawing! then batch\begin!
52 | else
53 | if matrixDirty
54 | shapes\setTransformMatrix matrix
55 | matrixDirty = false
56 |
57 | if batch\isDrawing! then YaeVM.util\endBatch batch
58 | if not shapes\isDrawing! then shapes\begin!
59 |
60 | ---
61 | -- Draws a filled or unfilled arc at position (x, y). The arc is drawn from
62 | -- angle1 to angle2 in radians.
63 | -- @string mode How to draw the arc.
64 | -- @number x The position of the center along x-axis.
65 | -- @number y The position of the center along y-axis.
66 | -- @number radius Radius of the arc.
67 | -- @number angle1 The angle at which the arc begins.
68 | -- @number angle2 The angle at which the arc terminates.
69 | -- @usage
70 | -- -- Drawing half a circle
71 | -- yae.draw = ->
72 | -- yae.graphics.arc( "fill", 400, 300, 100, 0, math.pi )
73 | --
74 | -- -- Drawing Pacman
75 | -- pacwidth = math.pi / 6 -- size of his mouth
76 | -- yae.draw = ->
77 | -- yae.graphics.setColor( 255, 255, 0 ) -- pacman needs to be yellow
78 | -- yae.graphics.arc( "fill", 400, 300, 100, pacwidth, (math.pi * 2) - pacwidth )
79 | arc = (mode, x, y, radius, angle1, angle2) ->
80 | check false
81 | shapes\set Constants.shapetypes[mode]
82 | shapes\arc x, y, radius, math.deg(angle1), math.deg(angle2)
83 |
84 | circle = (mode, x, y, radius) ->
85 | check false
86 | shapes\set Constants.shapetypes[mode]
87 | shapes\circle x, y, radius
88 |
89 | clear = ->
90 | Gdx.gl\glClearColor background.r, background.g, background.b, background.a
91 | Gdx.gl\glClear GL20.GL_COLOR_BUFFER_BIT
92 |
93 | draw = (image, x=0, y=0, r=0, sx=1, sy=1, ox=0, oy=0) ->
94 | check true
95 |
96 | w = image\getWidth!
97 | h = image\getHeight!
98 | srcX = 0
99 | srcY = 0
100 | srcW = w
101 | srcH = h
102 | x -= ox
103 | y -= oy
104 |
105 | batch\draw image.texture, x, y, ox, oy, w, h, sx, sy, r, srcX, srcY, srcW, srcH, false, true
106 |
107 | drawq = (image, quad, x=0, y=0, r=0, sx=1, sy=1, ox=0, oy=0) ->
108 | check true
109 |
110 | w = quad.width
111 | h = quad.height
112 | srcX = quad.x
113 | srcY = quad.y
114 | srcW = quad.sw
115 | srcH = quad.sh
116 | x -= ox
117 | y -= oy
118 |
119 | batch\draw image.texture, x, y, ox, oy, w, h, sx, sy, r, srcX, srcY, srcW, srcH, false, true
120 |
121 | ellipse = (mode, x, y, width, height) ->
122 | check false
123 | shapes\set Constants.shapetypes[mode]
124 | shapes\ellipse x, y, width, height
125 |
126 | getBackgroundColor = ->
127 | return background.r * 255, background.g * 255, background.b * 255, background.a * 255
128 |
129 | getBlendMode = ->
130 | return blending
131 |
132 | getColor = ->
133 | return color.r * 255, color.g * 255, color.b * 255, color.a * 255
134 |
135 | getFont = ->
136 | return font
137 |
138 | line = (x1, y1, x2, y2) ->
139 | check false
140 | shapes\line x1, y1, x2, y2
141 |
142 | newFont = (filename, size, filetype) ->
143 | return Font filename, size, filetype
144 |
145 | newImage = (filename, format, filetype) ->
146 | return Image filename, format, filetype
147 |
148 | newQuad = (x, y, width, height, sw, sh) ->
149 | return Quad x, y, width, height, sw, sh
150 |
151 | origin = ->
152 | matrix\idt!
153 | matrixDirty = true
154 |
155 | point = (x, y) ->
156 | check false
157 | shapes\point x, y, 0
158 |
159 | polygon = (mode, ...) ->
160 | check false
161 | shapes\set Constants.shapetypes[mode]
162 | args = table.pack ...
163 |
164 | if type args[1] == "table"
165 | shapes\polygon args[1]
166 | else
167 | shapes\polygon args
168 |
169 | present = ->
170 | if shapes\isDrawing! then YaeVM.util\endShapes shapes
171 | if batch\isDrawing! then YaeVM.util\endBatch batch
172 |
173 | print = (text, x=0, y=0, r=0, sx=1, sy=1, ox=0, oy=0) ->
174 | check true
175 | tmp = nil
176 |
177 | if r != 0
178 | tmp = batch\getTransformMatrix!
179 | translate x, y
180 | rotate r
181 | translate -x, -y
182 | batch\setTransformMatrix matrix
183 | matrixDirty = false
184 |
185 | font.font\getData!\setScale sx, -sy
186 | font.font\draw batch, text, x - ox * sx, y - oy * sy
187 |
188 | if r != 0
189 | translate x, y
190 | rotate -r
191 | translate -x, -y
192 | batch\setTransformMatrix tmp
193 | matrixDirty = false
194 |
195 | printf = (text, width=0, align="left", x=0, y=0, r=0, sx=1, sy=1, ox=0, oy=0) ->
196 | check true
197 | tmp = nil
198 |
199 | if r != 0
200 | tmp = batch\getTransformMatrix!
201 | translate x, y
202 | rotate r
203 | translate -x, -y
204 | batch\setTransformMatrix matrix
205 | matrixDirty = false
206 |
207 | font.font\getData!\setScale sx, -sy
208 | font.font\draw batch, text, x - ox * sx, y - oy * sy, width, Constants.aligns[align], true
209 |
210 | if r != 0
211 | translate x, y
212 | rotate -r
213 | translate -x, -y
214 | batch\setTransformMatrix tmp
215 | matrixDirty = false
216 |
217 | rectangle = (mode, x, y, width, height) ->
218 | check false
219 | shapes\set Constants.shapetypes[mode]
220 |
221 | shapes\rect x, y, width, height
222 |
223 | reset = ->
224 | shader = SpriteBatch\createDefaultShader!
225 | batch\setShader shader
226 |
227 | background\set 0.4, 0.3, 0.4, 1
228 | color\set 1, 1, 1, 1
229 |
230 | batch\setColor color
231 | shapes\setColor color
232 | font.font\setColor color
233 | matrix\idt!
234 | matrixDirty = true
235 |
236 | rotate = (radians) ->
237 | matrix\rotate 0, 0, 1, math.deg(radians)
238 | matrixDirty = true
239 |
240 | scale = (sx, sy) ->
241 | matrix\scale sx, sy, 1
242 | matrixDirty = true
243 |
244 | setBackgroundColor = (r, g, b, a=255) ->
245 | background\set r / 255, g / 255, b / 255, a / 255
246 |
247 | setBlendMode = (mode) ->
248 | blending = mode
249 | blendmode = Constants.blendmodes[blending]
250 | batch\setBlendFunction blendmode[1], blendmode[2]
251 |
252 | setColor = (r, g, b, a=255) ->
253 | color\set r / 255, g / 255, b / 255, a / 255
254 | batch\setColor color
255 | shapes\setColor color
256 | font.font\setColor color
257 |
258 | setFont = (newFont) ->
259 | font = newFont
260 |
261 | setNewFont = (filename, size, filetype) ->
262 | font = newFont filename, size, filetype
263 |
264 | translate = (tx, ty) ->
265 | matrix\translate tx, ty, 0
266 | matrixDirty = true
267 |
268 | {
269 | :arc
270 | :circle
271 | :clear
272 | :draw
273 | :drawq
274 | :ellipse
275 | :getBackgroundColor
276 | :getBlendMode
277 | :getColor
278 | :getFont
279 | :line
280 | :newFont
281 | :newImage
282 | :newQuad
283 | :origin
284 | :point
285 | :polygon
286 | :present
287 | :print
288 | :printf
289 | :rectangle
290 | :reset
291 | :rotate
292 | :scale
293 | :setBackgroundColor
294 | :setBlendMode
295 | :setColor
296 | :setFont
297 | :setNewFont
298 | :translate
299 | }
300 |
--------------------------------------------------------------------------------
/src/yae/java.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- Provides direct access to Java
3 | -------------------------------------------------------------------------------
4 | -- @module yae.java
5 |
6 | ---
7 | -- Bind Java object to Lua
8 | -- @tparam string name Java object name
9 | -- @treturn Object a Java object converted to Lua
10 | -- @usage
11 | -- System = java.bind "java.lang.System"
12 | -- print System\currentTimeMillis!
13 | require = luajava.bindClass
14 |
15 | ---
16 | -- Create new instance of specified Java object
17 | -- @tparam string name Java object name
18 | -- @param ... constructor parameters
19 | -- @treturn Object an instance of specified Java class
20 | -- @usage
21 | -- Scanner = java.require "java.util.Scanner"
22 | -- scanner = java.new Scanner, "1 fish 2 fish red fish blue fish"
23 | -- scanner\useDelimiter "\\s*fish\\s*"
24 | -- print scanner\next!
25 | new = luajava.new
26 |
27 | ---
28 | -- Extend specified Java object
29 | -- @tparam string name Java object name
30 | -- @tparam table options options
31 | -- @treturn Object an extended Java object
32 | -- @usage
33 | -- runnable = java.extend "java.lang.Runnable",
34 | -- run: ->
35 | extend = luajava.createProxy
36 |
37 | {
38 | :require
39 | :new
40 | :extend
41 | }
42 |
--------------------------------------------------------------------------------
/src/yae/keyboard.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- User input from keyboard.
3 | -------------------------------------------------------------------------------
4 | -- Keyboards signal user input by generating events for pressing and releasing
5 | -- a key. Each event carries with it a key-code that identifies the key that
6 | -- was pressed/released. These key-codes differ from platform to platform.
7 | -- Yae tries to hide this fact by providing its own key-code table. You can
8 | -- query which keys are currently being pressed via polling.
9 | --
10 | -- @module yae.keyboard
11 |
12 | import java from yae
13 | Gdx = java.require "com.badlogic.gdx.Gdx"
14 | Peripheral = java.require "com.badlogic.gdx.Input$Peripheral"
15 | Constants = require "yae.constants"
16 |
17 | ---
18 | -- Checks if keyboard is available on current device
19 | -- @treturn bool True if keyboard is available
20 | -- @usage
21 | -- available = yae.keyboard.isAvailable!
22 | isAvailable = ->
23 | isVisible or Gdx.input\isPeripheralAvailable Peripheral.HardwareKeyboard
24 |
25 | ---
26 | -- Check if one of specified keys is down
27 | -- @tparam ... keys keys to check for
28 | -- @treturn bool true one of keys is pressed
29 | -- @usage
30 | -- is_down = yae.keyboard.isDown "a", "b", "c"
31 | -- @see keys.moon
32 | isDown = (...) ->
33 | args = table.pack ...
34 | found = false
35 |
36 | for i = 1, args.n
37 | keycode = Constants.keys[args[i]]
38 | found = found or Gdx.input\isKeyPressed keycode
39 |
40 | found
41 |
42 | ---
43 | -- Checks if on-screen keyboard is visible (mobile devices only)
44 | -- @treturn bool true if keyboard is visible
45 | -- @usage
46 | -- visible = yae.keyboard.isVisible!
47 | isVisible = ->
48 | Gdx.input\isPeripheralAvailable Peripheral.OnscreenKeyboard
49 |
50 | ---
51 | -- Change on-screen keyboard visibility (mobile devices only)
52 | -- @tparam bool visible set if keyboard will be visible or not
53 | -- @usage
54 | -- yae.keyboard.setVisible true
55 | setVisible = (visible) ->
56 | Gdx.input\setOnscreenKeyboardVisible visible
57 |
58 | {
59 | :isDown
60 | :isVisible
61 | :isAvailable
62 | :setVisible
63 | }
64 |
--------------------------------------------------------------------------------
/src/yae/mouse.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- User input from mouse (works only on desktop devices).
3 | -------------------------------------------------------------------------------
4 | -- Mouse and touch input allow the user to point at things on the screen. Both
5 | -- input mechanisms report the location of interaction as 2D coordinates
6 | -- relative to the upper left corner of the screen, with the positive x-axis
7 | -- pointing to the right and the y-axis pointing downward.
8 | --
9 | -- Mouse input comes with additional information, namely which button was
10 | -- pressed. Most mice feature a left and a right mouse button as well as a
11 | -- middle mouse button. In addition, there's often a scroll wheel which can be
12 | -- used for zooming or scrolling in many applications.
13 | --
14 | -- @module yae.mouse
15 |
16 | import java from yae
17 | Gdx = java.require "com.badlogic.gdx.Gdx"
18 | Constants = require "yae.constants"
19 |
20 | ---
21 | -- Get X coordinate of mouse cursor position
22 | -- @treturn number x coordinate
23 | -- @usage
24 | -- x = yae.mouse.getX!
25 | getX = ->
26 | Gdx.input\getX!
27 |
28 | ---
29 | -- Get Y coordinate of mouse cursor position
30 | -- @treturn number y coordinate
31 | -- @usage
32 | -- y = yae.mouse.getY!
33 | getY = ->
34 | Gdx.input\getY!
35 |
36 | ---
37 | -- Get mouse cursor position
38 | -- @treturn number x coordinate of the cursor
39 | -- @treturn number y coordinate of the cursor
40 | -- @usage
41 | -- x, y = yae.mouse.getPosition!
42 | getPosition = ->
43 | getX!, getY!
44 |
45 | ---
46 | -- Check if one of specified buttons is down
47 | -- @tparam ... buttons buttons to check for
48 | -- @treturn bool true one of buttons is pressed
49 | -- @usage
50 | -- isDown = yae.mouse.isDown "left", "right"
51 | -- @see buttons.moon
52 | isDown = (...) ->
53 | args = table.pack ...
54 | found = false
55 |
56 | for i = 1, args.n
57 | btncode = Constants.buttons[args[i]]
58 | found = found or Gdx.input\isButtonPressed btncode
59 |
60 | return found
61 |
62 | ---
63 | -- Check if mouse cursor is visible
64 | -- @treturn bool true if cursor is visible
65 | -- @usage
66 | -- visible = yae.mouse.isVisible!
67 | isVisible = ->
68 | not Gdx.input\isCursorCatched!
69 |
70 | ---
71 | -- Set mouse cursor position
72 | -- @tparam number x the x coordinate
73 | -- @tparam number y the y coordinate
74 | -- @usage
75 | -- yae.mouse.setPosition 10, 10
76 | setPosition = (x, y) ->
77 | Gdx.input\setCursorPosition x, y
78 |
79 | ---
80 | -- Change mouse cursor visibility
81 | -- @tparam bool visible set if cursor will be visible or not
82 | -- @usage
83 | -- yae.mouse.setVisible true
84 | setVisible = (visible) ->
85 | Gdx.input\setCursorCatched not visible
86 |
87 | ---
88 | -- Set X coordinate of mouse cursor position
89 | -- @tparam number x the x coordinate
90 | -- @usage
91 | -- yae.mouse.setX 10
92 | setX = (x) ->
93 | setPosition x, getY!
94 |
95 | ---
96 | -- Set Y coordinate of mouse cursor position
97 | -- @tparam number y the y coordinate
98 | -- @usage
99 | -- yae.mouse.setY 10
100 | setY = (y) ->
101 | setPosition getX!, y
102 |
103 | {
104 | :getX
105 | :getY
106 | :getPosition
107 | :isDown
108 | :isVisible
109 | :setPosition
110 | :setVisible
111 | :setX
112 | :setY
113 | }
114 |
--------------------------------------------------------------------------------
/src/yae/objects/File.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- Represents a file on the filesystem.
3 | -------------------------------------------------------------------------------
4 | -- @classmod yae.File
5 |
6 | Gdx = yae.java.require "com.badlogic.gdx.Gdx"
7 | YaeVM = yae.java.require "yae.YaeVM"
8 |
9 | class
10 | new: (filename, filetype="internal") =>
11 | switch filetype
12 | when "internal"
13 | @file = Gdx.files\internal filename
14 | when "local"
15 | @file = YaeVM.util\localfile filename
16 | when "external"
17 | @file = Gdx.files\external
18 | when "classpath"
19 | @file = Gdx.files\classpath
20 | when "absolute"
21 | @file = Gdx.files\absolute
22 |
23 | ---
24 | -- Append data to an existing file.
25 | -- @tparam File self
26 | -- @string text The string data to append to the file.
27 | -- @usage
28 | -- File\append text
29 | append: (text) =>
30 | @file\writeString text, true
31 |
32 | ---
33 | -- Copy file.
34 | -- @tparam File self
35 | -- @tparam File to The destination file.
36 | -- @usage
37 | -- File\copy to
38 | copy: (to) =>
39 | @file\copyTo to
40 |
41 | createDirectory: =>
42 | @file\mkdirs!
43 |
44 | exists: =>
45 | @file\exists!
46 |
47 | getDirectoryItems: =>
48 | children = @file\list!
49 | paths = {}
50 |
51 | for i = 0, children.length
52 | paths[i + 1] = children[i]\path!
53 |
54 | paths
55 |
56 | getLastModified: =>
57 | @file\lastModified!
58 |
59 | getSize: =>
60 | @file\length!
61 |
62 | isDirectory: =>
63 | @file\isDirectory!
64 |
65 | isFile: =>
66 | not @is_directory!
67 |
68 | move: (to_file) =>
69 | @file\moveTo to_file
70 |
71 | read: =>
72 | @file\readString!
73 |
74 | remove: =>
75 | @file\deleteDirectory!
76 |
77 | write: (text) =>
78 | @file\writeString text
79 |
--------------------------------------------------------------------------------
/src/yae/objects/Font.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- Defines the shape of characters that can be drawn onto the screen.
3 | -------------------------------------------------------------------------------
4 | -- @classmod yae.Font
5 |
6 | FreeTypeFontGenerator = yae.java.require "com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator"
7 | GlyphLayout = yae.java.require "com.badlogic.gdx.graphics.g2d.GlyphLayout"
8 | Constants = require "yae.constants"
9 |
10 | class
11 | new: (filename, size=16, filetype) =>
12 | file = nil
13 |
14 | if filename == nil
15 | file = yae.File("yae/font.ttf", filetype)
16 | else
17 | file = yae.File(filename, filetype)
18 |
19 | generator = yae.java.new FreeTypeFontGenerator, file.file
20 | @font = generator\generateFont size
21 | @fontTexture = @font\getRegion(0)\getTexture!
22 | @fontTexture\setFilter Constants.filters["linear"], Constants.filters["linear"]
23 | @glyphLayout = yae.java.new GlyphLayout
24 |
25 | getAscent: =>
26 | @font\getAscent!
27 |
28 | getDescent: =>
29 | @font\getDescent!
30 |
31 | getLineHeight: =>
32 | @font\getLineHeight!
33 |
34 | getBounds: (text) =>
35 | @glyphLayout\setText text
36 | @glyphLayout.width, @glyphLayout.height
37 |
38 | getFilter: =>
39 | min_filter = @fontTexture\getMinFilter!
40 | mag_filter = @fontTexture\getMagFilter!
41 | Constants.filtercodes[min_filter], Constants.filtercodes[mag_filter]
42 |
43 | getHeight: (text) =>
44 | _, h = @getBounds text
45 | h
46 |
47 | getWidth: (text) =>
48 | w, _ = @getBounds text
49 | w
50 |
51 | hasGlyphs: (...) =>
52 | args = table.pack ...
53 | found = true
54 |
55 | for i = 1, args.n
56 | found = found and @font\containsCharacter args[i]
57 |
58 | found
59 |
60 | setFilter: (min, mag) =>
61 | @fontTexture\setFilter Constants.filters[min], Constants.filters[mag]
62 |
63 | setLineHeight: (height) =>
64 | @font\getData()\setLineHeight height
65 |
66 | free: =>
67 | @font\dispose!
68 |
--------------------------------------------------------------------------------
/src/yae/objects/Image.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- Drawable image type
3 | -------------------------------------------------------------------------------
4 | -- @classmod yae.Image
5 |
6 | Texture = yae.java.require "com.badlogic.gdx.graphics.Texture"
7 | Constants = require "yae.constants"
8 |
9 | class
10 | new: (filename, format="rgba8", filetype) =>
11 | file = yae.File(filename, filetype)
12 | @texture = yae.java.new Texture, file.file, Constants.formats[format], false
13 | @texture\setFilter Constants.filters["linear"], Constants.filters["linear"]
14 |
15 | getDimensions: =>
16 | @getWidth!, @getHeight!
17 |
18 | getFilter: =>
19 | min_filter = @texture\getMinFilter!
20 | mag_filter = @texture\getMagFilter!
21 | Constants.filtercodes[min_filter], Constants.filtercodes[mag_filter]
22 |
23 | getFormat: =>
24 | texture_data = @texture\getTextureData!
25 | format = texture_data\getFormat!
26 | Constants.formatcodes[format]
27 |
28 | getHeight: =>
29 | @texture\getHeight!
30 |
31 | getWidth: =>
32 | @texture\getWidth!
33 |
34 | getWrap: =>
35 | Constants.wraps[@texture\getUWrap!], Constants.wraps[@texture\getVWrap!]
36 |
37 | setFilter: (min, mag) =>
38 | @texture\setFilter Constants.filters[min], Constants.filters[mag]
39 |
40 | setWrap: (horiz, vert) =>
41 | @texture\setWrap Constants.wraps[horiz], Constants.wraps[vert]
42 |
43 | free: =>
44 | @texture\dispose!
45 |
--------------------------------------------------------------------------------
/src/yae/objects/Quad.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- A quadrilateral (a polygon with four sides and four corners) with texture
3 | -- coordinate information.
4 | -------------------------------------------------------------------------------
5 | -- @classmod yae.Quad
6 |
7 | class
8 | new: (x, y, w, h, sw, sh) =>
9 | @x = x
10 | @y = y
11 | @w = w
12 | @h = h
13 | @sw = sw
14 | @sh = sh
15 |
16 | ---
17 | -- Gets the current viewport of this Quad.
18 | -- @tparam Quad self
19 | -- @treturn number x The top-left corner along the x-axis.
20 | -- @treturn number y The top-right corner along the y-axis.
21 | -- @treturn number w The width of the viewport.
22 | -- @treturn number h The height of the viewport.
23 | -- @usage
24 | -- x, y, width, height = Quad\getViewport!
25 | getViewport: =>
26 | @x, @y, @w, @h
27 |
28 | ---
29 | -- Sets the texture coordinates according to a viewport.
30 | -- @tparam Quad self
31 | -- @number x The top-left corner along the x-axis.
32 | -- @number y The top-right corner along the y-axis.
33 | -- @number w The width of the viewport.
34 | -- @number h The height of the viewport.
35 | -- @usage
36 | -- Quad\setViewport x, y, width, height
37 | setViewport: (x, y, w, h) =>
38 | @x = x
39 | @y = y
40 | @w = w
41 | @h = h
42 |
--------------------------------------------------------------------------------
/src/yae/objects/Source.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- A Source represents audio you can play back.
3 | -------------------------------------------------------------------------------
4 | -- @classmod yae.Source
5 |
6 | Gdx = yae.java.require "com.badlogic.gdx.Gdx"
7 |
8 | class
9 | ---
10 | -- Creates a new Source from a filepath.
11 | -- @tparam Source self
12 | -- @string filename The name (and path) of the file.
13 | -- @string[opt="stream"] audiotype Type of the audio.
14 | -- @string[opt="internal"] filetype Type of the file
15 | -- @treturn Source A new Source that can play the specified audio.
16 | -- @usage
17 | -- source = Source(filename, audiotype, filetype)
18 | new: (filename, audiotype="stream", filetype) =>
19 | file = yae.File(filename, filetype)
20 | @static = audiotype != "stream"
21 | @volume = 1
22 | @looping = false
23 | @playing = false
24 | @paused = false
25 |
26 | if @static
27 | @source = Gdx.audio\newMusic file.file
28 | else
29 | @source = Gdx.audio\newSound file.file
30 |
31 | ---
32 | -- Starts playing the Source.
33 | -- @tparam Source self
34 | -- @usage
35 | -- Source\play!
36 | play: =>
37 | if @static
38 | @soundId = @source\play!
39 | else
40 | @source\play!
41 |
42 | @playing = false
43 |
44 | ---
45 | -- Pauses the Source
46 | -- @tparam Source self
47 | -- @usage
48 | -- Source\pause!
49 | pause: =>
50 | if @paused return
51 |
52 | if @static
53 | @source\pause @soundId
54 | else
55 | @source\pause!
56 |
57 | @paused = true
58 |
59 | ---
60 | -- Resumes a paused Source
61 | -- @tparam Source self
62 | -- @usage
63 | -- Source\resume!
64 | resume: =>
65 | if not @paused return
66 |
67 | if @static
68 | @source\pause @soundId
69 | else
70 | @source\pause!
71 |
72 | ---
73 | -- Stops a Source
74 | -- @tparam Source self
75 | -- @usage
76 | -- Source\stop!
77 | stop: =>
78 | if not @playing return
79 |
80 | if @static
81 | @source\stop @soundId
82 |
83 | else
84 | @source\stop!
85 |
86 | @playing = true
87 |
88 | ---
89 | -- Returns a type of a Source
90 | -- @tparam Source self
91 | -- @treturn string Type of a Source ("static" or "stram")
92 | -- @usage
93 | -- type = Source\getType!
94 | getType: =>
95 | @static and "static" or "stream"
96 |
97 | ---
98 | -- Gets the current volume of the Source.
99 | -- @tparam Source self
100 | -- @treturn number Volume of a Source
101 | -- @usage
102 | -- volume = Source\getVolume!
103 | getVolume: =>
104 | @volume
105 |
106 | ---
107 | -- Returns whether the Source will loop.
108 | -- @tparam Source self
109 | -- @treturn bool True if the Source will loop, false otherwise.
110 | -- @usage
111 | -- loop = Source\isLooping!
112 | isLooping: =>
113 | @looping
114 |
115 | ---
116 | -- Returns whether the Source is paused.
117 | -- @tparam Source self
118 | -- @treturn bool True if the Source is paused, false otherwise.
119 | -- @usage
120 | -- paused = Source\isPaused!
121 | isPaused: =>
122 | @paused
123 |
124 | ---
125 | -- Returns whether the Source is playing.
126 | -- @tparam Source self
127 | -- @treturn bool True if the Source is playing, false otherwise.
128 | -- @usage
129 | -- playing = Source\isPlaying!
130 | isPlaying: =>
131 | @playing
132 |
133 | ---
134 | -- Returns whether the Source is stopped.
135 | -- @tparam Source self
136 | -- @treturn bool True if the Source is stopped, false otherwise.
137 | -- @usage
138 | -- stopped = Source\isStopped!
139 | isStopped: =>
140 | not @playing
141 |
142 | ---
143 | -- Sets whether the Source should loop.
144 | -- @tparam File self
145 | -- @tparam bool looping True if the source should loop, false otherwise.
146 | -- @usage
147 | -- Source\setLooping looping
148 | setLooping: (looping) =>
149 | @looping = looping
150 |
151 | if @static
152 | @source\setLooping @soundId, @looping
153 | else
154 | @source\setLooping @looping
155 |
156 | ---
157 | -- Sets the current volume of the Source.
158 | -- @tparam File self
159 | -- @tparam number volume The volume for a Source, where 1.0 is normal volume.
160 | -- Volume cannot be raised above 1.0.
161 | -- @usage
162 | -- Source\setVolume volume
163 | setVolume: (volume) =>
164 | @volume = volume
165 |
166 | if @static
167 | @source\setVolume @soundId, @volume
168 | else
169 | @source\setVolume @volume
170 |
171 | free: =>
172 | @source\dispose!
173 |
--------------------------------------------------------------------------------
/src/yae/system.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- Provides many usefull methods for managing your current device.
3 | -------------------------------------------------------------------------------
4 | -- @module yae.system
5 |
6 | import java from yae
7 | Gdx = java.require "com.badlogic.gdx.Gdx"
8 | YaeVM = java.require "yae.YaeVM"
9 |
10 | ---
11 | -- Gets text from the clipboard.
12 | -- @treturn string The text currently held in the system's clipboard.
13 | -- @usage
14 | -- text = yae.system.getClipboardText!
15 | getClipboardText = ->
16 | clipboard = Gdx.app\getClipboard!
17 | clipboard\getContents!
18 |
19 | ---
20 | -- Get current platform. Can return "desktop", "android", "ios" or "unknown"
21 | -- @treturn string current platform
22 | -- @usage
23 | -- platform = yae.system.getOS!
24 | getOS = ->
25 | YaeVM.util\getOS!
26 |
27 | ---
28 | -- Get info about current memory usage
29 | -- @treturn number memory heap
30 | -- @usage
31 | -- heap = yae.system.getMemoryInfo!
32 | getMemoryInfo = ->
33 | Gdx.app\getJavaHeap!
34 |
35 | ---
36 | -- Opens a URL with the user's web or file browser.
37 | -- @tparam string url The URL to open. Must be formatted as a proper URL.
38 | -- @treturn bool Whether the URL was opened successfully.
39 | -- @usage
40 | -- success = yae.system.openURL url
41 | openURL = (url) ->
42 | Gdx.net\openURI url
43 |
44 | ---
45 | -- Puts text in the clipboard.
46 | -- @tparam string text The new text to hold in the system's clipboard.
47 | -- @usage
48 | -- yae.system.setClipboardText text
49 | setClipboardText = (text) ->
50 | clipboard = Gdx.app\getClipboard!
51 | clipboard\setContents text
52 |
53 | ---
54 | -- Vibrates for the given amount of time.
55 | -- @tparam number seconds the number of seconds to vibrate
56 | -- @usage
57 | -- yae.system.vibrate seconds
58 | vibrate = (seconds) ->
59 | Gdx.input\vibrate seconds * 1000
60 |
61 | ---
62 | -- Terminate the application
63 | -- @usage
64 | -- yae.system.quit! if something
65 | quit = ->
66 | Gdx.app\exit!
67 |
68 | {
69 | :getClipboardText
70 | :getOS
71 | :getMemoryInfo
72 | :openURL
73 | :setClipboardText
74 | :vibrate
75 | :quit
76 | }
77 |
--------------------------------------------------------------------------------
/src/yae/timer.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- Provides high-resolution timing functionality.
3 | -------------------------------------------------------------------------------
4 | -- @module yae.timer
5 |
6 | import java from yae
7 | TimeUtils = java.require "com.badlogic.gdx.utils.TimeUtils"
8 | Thread = java.require "java.lang.Thread"
9 | Gdx = java.require "com.badlogic.gdx.Gdx"
10 |
11 | ---
12 | -- Returns the time between the last two frames.
13 | -- @treturn number The time passed (in seconds).
14 | -- @usage
15 | -- dt = yae.timer.getDelta!
16 | getDelta = ->
17 | Gdx.graphics\getDeltaTime! / 1000
18 |
19 | ---
20 | -- Returns the current frames per second.
21 | -- @treturn number The current FPS.
22 | -- @usage
23 | -- fps = yae.timer.getFPS!
24 | getFPS = ->
25 | Gdx.graphics\getFramesPerSecond!
26 |
27 | ---
28 | -- Returns the value of a timer with an unspecified starting time. This
29 | -- function should only be used to calculate differences between points
30 | -- in time, as the starting time of the timer is unknown.
31 | -- @treturn number The time in seconds.
32 | -- @usage
33 | -- time = yae.timer.getTime!
34 | getTime = ->
35 | TimeUtils\millis! / 1000
36 |
37 | ---
38 | -- Pauses the current thread for the specified amount of time.
39 | -- @tparam number seconds Seconds to sleep for.
40 | -- @usage
41 | -- yae.timer.sleep seconds
42 | sleep = (seconds) ->
43 | Thread\sleep seconds * 1000
44 |
45 | {
46 | :getDelta
47 | :getFPS
48 | :getTime
49 | :sleep
50 | }
51 |
--------------------------------------------------------------------------------
/src/yae/touch.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- User input from touch screen (works only on mobile devices).
3 | -------------------------------------------------------------------------------
4 | -- Note that touch can be implemented quite differently on different devices.
5 | -- This can affect how pointer indexes are specified and released and when
6 | -- touch events are fired. Be sure to test your control scheme on as many
7 | -- devices as possible. There are also many input test apps available in the
8 | -- market which can help determine how a particular device reports touch and
9 | -- aid in designing a control scheme that works best across a range of devices.
10 | --
11 | -- @module yae.touch
12 |
13 | import java from yae
14 | Gdx = java.require "com.badlogic.gdx.Gdx"
15 |
16 | ---
17 | -- Get X coordinate of finger touching the screen
18 | -- @number[opt=0] pointer index of finger touching the screen for multitouch devices
19 | -- @treturn number x coordinate
20 | -- @usage
21 | -- x = yae.touch.getX 1
22 | getX = (pointer=0) ->
23 | Gdx.input\getX pointer
24 |
25 | ---
26 | -- Get Y coordinate of finger touching the screen
27 | -- @number[opt=0] pointer index of finger touching the screen for multitouch devices
28 | -- @treturn number y coordinate
29 | -- @usage
30 | -- y = yae.touch.getY 1
31 | getY = (pointer=0) ->
32 | Gdx.input\getY pointer
33 |
34 | ---
35 | -- Get the position of finger touching the screen
36 | -- @number[opt=0] pointer index of finger touching the screen for multitouch devices
37 | -- @treturn number x coordinate
38 | -- @treturn number y coordinate
39 | -- @usage
40 | -- x, y = yae.touch.getPosition 1
41 | getPosition = (pointer) ->
42 | getX pointer, getY pointer
43 |
44 | ---
45 | -- Check if finger is touching the screen
46 | -- @number[opt=0] pointer index of finger touching the screen for multitouch devices
47 | -- @treturn bool true if finger is touching the screen
48 | -- @usage
49 | -- touching = yae.touch.isDown 1
50 | isDown = (pointer=0) ->
51 | Gdx.input\isTouched pointer
52 |
53 | {
54 | :getX
55 | :getY
56 | :getPosition
57 | :isDown
58 | }
59 |
--------------------------------------------------------------------------------
/src/yae/window.moon:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | -- Provides an interface for modifying and retrieving information about the
3 | -- program's window.
4 | -------------------------------------------------------------------------------
5 | -- @module yae.window
6 |
7 | import project, java from yae
8 | Gdx = java.require "com.badlogic.gdx.Gdx"
9 | windowTitle = project.name
10 |
11 | ---
12 | -- Converts a number from pixels to density-independent units.
13 | -- @number px The x-axis value of a coordinate in pixels.
14 | -- @number py The y-axis value of a coordinate in pixels.
15 | -- @treturn number x The converted x-axis value of the coordinate, in
16 | -- density-independent units.
17 | -- @treturn number y The converted y-axis value of the coordinate, in
18 | -- density-independent units.
19 | -- @usage
20 | -- x, y = yae.window.fromPixels px, py
21 | fromPixels = (px, py) ->
22 | scale = getPixelScale!
23 |
24 | if py != nil
25 | return px / scale, py / scale
26 |
27 | px / scale
28 |
29 | ---
30 | -- Gets a list of supported display modes.
31 | -- @treturn table modes A table of width/height pairs.
32 | -- (Note that this may not be in order.)
33 | -- @usage
34 | -- modes = yae.window.getDisplayModes!
35 | getDisplayModes = ->
36 | jmodes = Gdx.graphics.getDisplayModes!
37 | modes = {}
38 |
39 | for i = 0, jmodes.length
40 | modes[i + 1] = jmodes[i]
41 |
42 | modes
43 |
44 | ---
45 | -- Gets the display mode and properties of the window.
46 | -- @treturn number width Window width
47 | -- @treturn number height Window height
48 | -- @treturn number fullscreen True if window is fullscreen
49 | -- @usage
50 | -- width, height, fullscreen = yae.window.getMode!
51 | getMode = ->
52 | getWidth!, getHeight!, isFullscreen!
53 |
54 | ---
55 | -- Gets the height of the window.
56 | -- @treturn number The height of the window.
57 | -- @usage
58 | -- height = yae.window.getHeight!
59 | getHeight = ->
60 | Gdx.graphics\getHeight!
61 |
62 | ---
63 | -- Gets the DPI scale factor associated with the window. In Mac OS X with the
64 | -- window in a retina screen and the highdpi window flag enabled this will be
65 | -- 2.0, otherwise it will be 1.0.
66 | -- @treturn number The pixel scale factor associated with the window.
67 | -- @usage
68 | -- scale = yae.window.getPixelScale!
69 | getPixelScale = ->
70 | Gdx.graphics\getDensity!
71 |
72 | ---
73 | -- Gets the window title.
74 | -- @treturn string The current window title.
75 | -- @usage
76 | -- title = yae.window.getTitle!
77 | getTitle = ->
78 | windowTitle
79 |
80 | ---
81 | -- Gets the width of the window.
82 | -- @treturn number The width of the window.
83 | -- @usage
84 | -- width = yae.window.getWidth!
85 | getWidth = ->
86 | Gdx.graphics\getWidth!
87 |
88 | ---
89 | -- Gets whether the window is fullscreen.
90 | -- @treturn bool True if the window is fullscreen, false otherwise.
91 | -- @usage
92 | -- fullscreen = yae.window.isFullscreen!
93 | isFullscreen = ->
94 | Gdx.graphics\isFullscreen!
95 |
96 | ---
97 | -- Enters or exits fullscreen. The display to use when entering fullscreen is
98 | -- chosen based on which display the window is currently in, if multiple
99 | -- monitors are connected.
100 | -- @bool fullscreen Whether to enter or exit fullscreen mode.
101 | -- @usage
102 | -- yae.window.setFullscreen fullscreen
103 | setFullscreen = (fullscreen) ->
104 | setMode getWidth!, getHeight!, fullscreen
105 |
106 | ---
107 | -- Sets the display mode and properties of the window.
108 | -- @number width Display width.
109 | -- @number height Display height.
110 | -- @bool[opt=false] fullscreen Fullscreen (true), or windowed (false).
111 | -- @usage
112 | -- yae.window.setMode width, height, fullscreen
113 | setMode = (width, height, fullscreen=false) ->
114 | Gdx.graphics\setDisplayMode width, height, fullscreen
115 |
116 | ---
117 | -- Sets the window title. Do not works on Android and iOS.
118 | -- @string title The new window title.
119 | -- @usage
120 | -- yae.window.setTitle title
121 | setTitle = (title) ->
122 | windowTitle = title
123 | Gdx.graphics\setTitle windowTitle
124 |
125 | ---
126 | -- Converts a number from density-independent units to pixels.
127 | -- @number x The x-axis value of a coordinate in density-independent units to
128 | -- convert to pixels.
129 | -- @number y The y-axis value of a coordinate in density-independent units to
130 | -- convert to pixels.
131 | -- @treturn number px The converted x-axis value of the coordinate, in pixels.
132 | -- @treturn number py The converted y-axis value of the coordinate, in pixels.
133 | -- @usage
134 | -- px, py = yae.window.toPixels x, y
135 | toPixels = (x, y) ->
136 | scale = getPixelScale!
137 |
138 | if y != nil
139 | return x * scale, y * scale
140 |
141 | x * scale
142 |
143 | {
144 | :fromPixels
145 | :getMode
146 | :getFullscreenModes
147 | :getHeight
148 | :getWidth
149 | :isFullscreen
150 | :setFullscreen
151 | :setMode
152 | :setTitle
153 | :toPixels
154 | }
155 |
--------------------------------------------------------------------------------
/yae-dev-1.rockspec:
--------------------------------------------------------------------------------
1 | package = "yae"
2 | version = "dev-1"
3 |
4 | source = {
5 | url = "git://github.com/nondev/yae.git",
6 | }
7 |
8 | description = {
9 | summary = "Game engine for MoonScript, in MoonScript.",
10 | homepage = "https://yae.io",
11 | maintainer = "Tomas Slusny ",
12 | license = "MIT"
13 | }
14 |
15 | dependencies = {
16 | "lua >= 5.1",
17 | "moonscript"
18 | }
19 |
20 | build = {
21 | type = "command",
22 |
23 | install = {
24 | bin = { "bin/yae" }
25 | },
26 |
27 | platforms = {
28 | unix = {
29 | build_command = "sh build"
30 | },
31 | windows = {
32 | build_command = "build"
33 | }
34 | },
35 |
36 | copy_directories = { "core", "res", "src" }
37 | }
38 |
--------------------------------------------------------------------------------