r/lua • • May 16 '21

Lua scriptable game engine

Here's a 2d game engine i've been working on for zelda-esque top down RPGs.

The engine is written in C++ and it uses OpenGL for rendering, GLFW for window instantiation and input.

It can load json files generated by "tiled".

All gameplay related code is written in Lua, which is integrated into the C++ code via the standard lua C api. See "scripts" folder for the general form of these scripts.

to write a script for a game object you just make a lua file with a table called GameObject which includes the methods init and update. Look in GameObject.cpp for the full list of C functions exposed to lua

The main loop, rendering, file io and collision detection happen in C++ - and all gameplay specific code in lua. A single lua VM is used for all scripted game objects and i think a second one (with different C functions exposed) will be used to script the games UI.

Here is the code for it so far - I hope some of you will find it useful and / or informative for your own projects :)

https://github.com/JimMarshall35/Zelda-RPG-Engine

51 Upvotes

3 comments sorted by

1

u/__Ambition May 17 '21

Really cool project!

1

u/Jimmy-M-420 May 17 '21

Thank you 🙂

1

u/Mysterious-Ad6879 Jun 02 '21

Solarus engine is a action RPG like zelda engine Solarus engine