How to use Hump Gamestates and modular files?
Posted: Wed May 20, 2015 8:18 pm
Hi all. I'm using HUMP's gamestates library and my code is getting a little unruly in it's length. I have certain functions isolated in their own .lua files to keep things organized, which is a start, but I'm wondering how I can keep individual gamestates in their own files as well to keep things tidy and to save time hunting around my code. Fore example, how can I isolate menu and game into their own .lua files?
Code: Select all
Gamestate = require "gamestate"
local menu = {}
local game = {}
function love.load()
Gamestate.registerEvents()
Gamestate.switch(menu)
end
function menu:enter()
-- menu load out
end
function menu:update(dt)
-- many lines of code
end
function menu:draw()
-- many lines of code
end
function game:enter()
-- many lines of code
end
function game:update(dt)
-- many lines of code
end
function game:draw()
-- many lines of code
end