Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function love.load()
- keyconfig = {
- ["up"] = "MOVE_UP",
- ["down"] = "MOVE_DOWN",
- -- ...etc
- }
- keystate = {
- -- functions that actually move the player around or perform actions
- ["MOVE_UP"] = moveupfunction,
- ["MOVE_DOWN"] = movedownfunction
- -- ....etc
- }
- player.state = nil
- end
- function love.update(dt)
- if player.state then
- -- run function to update game based on key pressed
- keystate[player.state]()
- end
- end
- function love.draw()
- love.graphics.print( text, 330, 300 )
- end
- function love.keypressed( key )
- player.state = keyconfig[key]
- end
- function love.keyreleased( key )
- player.state = nil
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement