1. Macros:
Some variables for UI and drawing
__gamescale__ : double A handy double that represents the default size of anything drawn
btn_a : bool Will be true when button a is pressed
btn_b : bool Will be true when button b is pressed
btn_d : bool Will be true when the down button is pressed
btn_u : bool Will be true when the up button is pressed
btn_l : bool Will be true when the left button is pressed
btn_r : bool Will be true when the right button is pressed
2. Colors:
Colors are represented as numbers. They wrap so 17 = 0, 18 = 1 etc
0 Transparent
1 Black
2 Dark Grey
3 Light Grey
4 White
5 Beige
6 Hot Pink
7 Red
8 Burgundy
9 Brown
10 Orange
11 Yellow
12 Light Green
13 Dark Green
14 Light Blue
15 Violet
16 Dark Blue
3. Callbacks:
Functions that you can override to make your game
_init()
Called once at the start of program execution
_draw()
Called 30 times per second, safe place to call graphic methods
_update()
Called 30 times per second, safe place to respond to input (btn_l, btn_r etc.)
4. Draw Methods:
Functions that draw things to the game screen when you hit play
rectifll(x1: double, y1: double, x2: double, y2: double, color: double)
Draw a filled rectangle with x1:y1 being the top left corner and x2:y2 being the bottom right corner. Refer to Colors
log(text: String, x: double, y: double, color: double)
Write some text at a given point and with the requested color
cls()
Clear the screen to black
cls(color: number)
Clear the screen to a given color
sprite(no: double, x: double, y: double)
Draws a sprite at the given coordinates. Sprite numbers can be seen in the sprite editor between the sprite display windows and the sprite editor window
sprite(no: double, x: double,y: double,scale: double)
Same as above, but with optional scale parameter. Default is 4 (based on __gamescale__ constant)
sprite(no: double, x: double, y: double, scale: double,flip: bool)
Same as above, but with optional flip param. True is flipped, false is not.
sprite(no: double, x: double, y: double, scale: double, flip: bool, rotation: double)
Same as above but with 90 degree rotation increments (1 = 90, 2 = 180, 3 = 270, 0 = 360). Thiw will wrap automatically to the modulus of these 4 values
map(celx: double, cely: double, sx: double, sy: double, celw: double, celh: double)
Draw a segment of map from the map editor. celx:cely (from x, from y) the top left corner of the map to draw from. celw:cely the width and height of the map segment ti drawo, abd. sx:sy the position where the top left corner of the map will be drawn from
drawmap(fX: double, fY: double, tX: double, tY: double, x: double, y: double)
Draw a segment of map from the map editor. fX:fY (from x, from y) the top left corner of the map to draw from. tx:ty (to x, to y) the bottom right corner to draw too. x:y the top left corner of the screen that the map will be drawn from
5. Game Logic Methods:
Things I'm working on to make development easier
mget(x: double, y: double): double
Get the tile at a given position on the map.
areacontains(x: double, y: double, w: double, h: double, tile: double): bool
Query a rectangular segment of the map to see if it contains a given tile number. A clunky helper method for collision detection. Let me know how I can simplify this!!!
5. Debug methods
Handy methods for sanity checking all that spaghetti code
hlog(text: String)
Outputs text to a scrollable debug text area that overlays the game display
alert(text: String)
Throws up an alert dialog with some text and stops execution on the frame the alert was triggered on
hassert(result: bool, message: String)
Outputs either "Test Passed: " + message or "Test Failed: " + message to the debug text area. It was more for me to test things, but I left it in just in case someone needs it!
6. Pages
6.1 Code Editor
This is where you write in your lua code!
Initialise values in the _init callback:
Respond to user input in the _update callback:
Draw things in the _draw callback:
If you wrote all that in, press play in the top right corner and you should have a little white square that responds to the d-pad!
6.2 Menu
Fairly self explanatory, though 'Settings' doesn't do anything yet
6.3 Save Dialog
The current project should be displayed by default, but you can pick a new name or scroll through the list for any other projects saved to your device if you felt like writing over it! Tapping on one of these will just copy the text across, nothing is committed until you hit save.
6.4 Load Dialog
Like the save dialog, but opens projects instead. Again, you can scroll through the list and select any existing projects you have.
6.5 Import Page
This loads up a list of community-created projects. Tapping on one of them will save it to your device, at which point you can then return to the main window and use the Load Dialog to open it up and play it, modify it or whatever it is you wanted to do with it.
6.6 Export Dialog
Pick a name for the currently loaded project and send it in .json format by anything installed on your phone that can send text. If someone else has sent you a project file made in Handsome Console you can move it to Phone Storage>Android>data>com.example.luainterpreter>files and then load it from the Load Dialog.
6.7 Sprite Editor
You can edit some sprites here! The top radio buttons are different pages of sprites. Click on a sprite to load it into the editor. The number to the left of the pencil is the currently selected sprite number.
The pencil will draw a single cell of the selected color when you click on a space in the editor.
The paint bucket will replace all of one color with another color.
The eraser is like the pencil but with a fully transparent color loaded onto it.
The second last icon copies the currently loaded sprite to the clipboard.
The last icon pastes the sprite from the clipboard onto the currently selected sprite.
Clicking on a color in the color palette will change the pencil/paint bucket color.
6.8 Map Editor
You can use the map editor to create map regions which are just sprites glued together. You can click on the arrows to navigate across the map. the top left corner of the map, for purposes of using the drawmap function, is 0,0, and the bottom right corner is 127,127. Let me know if you ever run out of map space and I can easily make it bigger- it can't be too big though or things get slow.
6.9 Game Page
This is where you can play games! Should be idiomatic, there's a d-pad tied to the btn_d, btn_u, btn_l and btn_r macros for down, up, left and right respectively. btn_a and btn_b are tied to the buttons labelled A and B respectively!
Now go out there and make some games with it!