A 2D game engine built with C++ with Lua bindings with a builtin editor
The project is made with Visual Studio 2022, using VCPKG. Ensure you have these dependencies before building!
- Event.addEventListener(name:string, event:function)
Adds an event listener under the given event
- Event.removeEventListener(name:string, event:function)
Removes a previously registered event listener by reference
- Event.removeEventListenersFor(name:string)
Removes all previously registered event listeners for a given event
- Event.getEventListeners(name:string) -> [...]
Gets all listeners for a given event.
on_key_press -> (key:int)
- Fires when a key is pressed.on_key_hold -> (key:int)
- Fires while a key is held.on_key_release -> (key:int)
- Fires when a key is released.
on_mouse_click -> (x:int, y:int, left:bool, middle:bool, right:bool)
- Fires when clicking with a mouseon_mouse_move -> (x:int, y:int)
- Fires when moving the cursoron_mouse_scroll -> (amount_scrolled:float)
- Fires when scrolling
on_render -> ()
- Fires during the render loopon_gui -> ()
- Fires during the render loop, but after rendering the scene
These are general purpose game loop, or scene events.
on_update → ()
- Fires during the update loop (every frame)on_init → ()
- Fires when the scene finishes loading assetson_save → ()
- Fires when requested to saveon_load → (assets:{})
- Fires when requested to load assets. The assets will be provided in a JSON-like format.on_engine_exit → ()
- Fires before the game finishes exiting (will not occur during any crashes)on_engine_init → ()
- Fires when the game first loads (This event must be defined in the autoexec file)
- key_to_name(keycode:int) → string
Returns a readable version of the keycode.
Example: input.key_to_name(input.GLFW_KEY_A) → "a"
- key_down(keycode:int) → bool
Returns if the supplied keycode is being held
- key_pressed(keycode:int) → bool
Returns if the supplied keycode was pressed this frame
In lua, you can use input.GLFW_KEY_* to get direct key references. Lua-implemented names can be found below:
KeyCode Mappings
input.Key_A = 65
input.Key_B = 66
input.Key_C = 67
input.Key_D = 68
input.Key_E = 69
input.Key_F = 70
input.Key_G = 71
input.Key_H = 72
input.Key_I = 73
input.Key_J = 74
input.Key_K = 75
input.Key_L = 76
input.Key_M = 77
input.Key_N = 78
input.Key_O = 79
input.Key_P = 80
input.Key_Q = 81
input.Key_R = 82
input.Key_S = 83
input.Key_T = 84
input.Key_U = 85
input.Key_V = 86
input.Key_W = 87
input.Key_X = 88
input.Key_Y = 89
input.Key_Z = 90
TODO: paste rest of mappings!