- Integrated Lua 5.4 engine (32-bit mode for embedded ARM) - Created LuaGame wrapper class implementing Game interface - Added C++ bindings exposing renderer, game state, and input to Lua - Implemented SD card loader for automatic .lua game discovery - Updated GameLauncher to support std::function for lambda captures - Made Game class members public for Lua bindings access - Added example Lua games: counter, snake, bouncing ball - Included comprehensive API documentation Games can now be written as .lua text files on SD card and loaded without recompilation. Build size: 747KB UF2, Lua VM uses ~50-80KB RAM.
41 lines
1.4 KiB
C++
41 lines
1.4 KiB
C++
// ============================================================================
|
|
// LUA GAME LOADER - HEADER
|
|
// ============================================================================
|
|
// Scans SD card for .lua game scripts and registers them with GameLauncher
|
|
|
|
#ifndef LUA_GAME_LOADER_H
|
|
#define LUA_GAME_LOADER_H
|
|
|
|
#include "../lib/game_launcher.h"
|
|
|
|
/**
|
|
* @brief Lua Game Loader - discovers and registers Lua games from SD card
|
|
*/
|
|
class LuaGameLoader {
|
|
public:
|
|
/**
|
|
* @brief Scan SD card /games directory and register all .lua files
|
|
* @param launcher GameLauncher to register games with
|
|
* @return Number of Lua games found and registered
|
|
*/
|
|
static int register_all_games(GameLauncher* launcher);
|
|
|
|
private:
|
|
/**
|
|
* @brief Parse metadata from Lua script comments
|
|
* @param script_path Path to .lua file
|
|
* @param name Output: game name (default: filename)
|
|
* @param description Output: game description (default: empty)
|
|
* @return true if file could be read
|
|
*/
|
|
static bool parse_metadata(const char* script_path, char* name, char* description);
|
|
|
|
/**
|
|
* @brief Factory function for creating LuaGame instances
|
|
*/
|
|
static Game* create_lua_game(const char* script_path, uint16_t width, uint16_t height,
|
|
LowLevelRenderer* renderer, LowLevelGUI* gui, InputManager* input_manager);
|
|
};
|
|
|
|
#endif // LUA_GAME_LOADER_H
|