mirror of
https://github.com/vrld/hump.git
synced 2024-11-23 12:24:19 +00:00
Fixed a typo in the gamestate docs
Sorry about Atom doing its thing with empty lines...
This commit is contained in:
parent
5e02dcdba2
commit
7713d054b3
@ -13,30 +13,30 @@ A typical game could consist of a menu-state, a level-state and a game-over-stat
|
|||||||
|
|
||||||
local menu = {} -- previously: Gamestate.new()
|
local menu = {} -- previously: Gamestate.new()
|
||||||
local game = {}
|
local game = {}
|
||||||
|
|
||||||
function menu:draw()
|
function menu:draw()
|
||||||
love.graphics.print("Press Enter to continue", 10, 10)
|
love.graphics.print("Press Enter to continue", 10, 10)
|
||||||
end
|
end
|
||||||
|
|
||||||
function menu:keyreleased(key, code)
|
function menu:keyreleased(key, code)
|
||||||
if key == 'enter' then
|
if key == 'enter' then
|
||||||
Gamestate.switch(game)
|
Gamestate.switch(game)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function game:enter()
|
function game:enter()
|
||||||
Entities.clear()
|
Entities.clear()
|
||||||
-- setup entities here
|
-- setup entities here
|
||||||
end
|
end
|
||||||
|
|
||||||
function game:update(dt)
|
function game:update(dt)
|
||||||
Entities.update(dt)
|
Entities.update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function game:draw()
|
function game:draw()
|
||||||
Entities.draw()
|
Entities.draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
Gamestate.registerEvents()
|
Gamestate.registerEvents()
|
||||||
Gamestate.switch(menu)
|
Gamestate.switch(menu)
|
||||||
@ -101,6 +101,8 @@ corresponding LÖVE callbacks and receive receive the same arguments (e.g.
|
|||||||
**Example**::
|
**Example**::
|
||||||
|
|
||||||
menu = {} -- previously: Gamestate.new()
|
menu = {} -- previously: Gamestate.new()
|
||||||
|
|
||||||
|
function menu:init()
|
||||||
self.background = love.graphics.newImage('bg.jpg')
|
self.background = love.graphics.newImage('bg.jpg')
|
||||||
Buttons.initialize()
|
Buttons.initialize()
|
||||||
end
|
end
|
||||||
@ -295,11 +297,11 @@ to be one of the :ref:`callbacks`. Mostly useful when not using
|
|||||||
function love.draw()
|
function love.draw()
|
||||||
Gamestate.draw() -- <callback> is `draw'
|
Gamestate.draw() -- <callback> is `draw'
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
Gamestate.update(dt) -- pass dt to currentState:update(dt)
|
Gamestate.update(dt) -- pass dt to currentState:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keypressed(key, code)
|
function love.keypressed(key, code)
|
||||||
Gamestate.keypressed(key, code) -- pass multiple arguments
|
Gamestate.keypressed(key, code) -- pass multiple arguments
|
||||||
end
|
end
|
||||||
@ -332,7 +334,7 @@ This is by done by overwriting the love callbacks, e.g.::
|
|||||||
Gamestate.registerEvents()
|
Gamestate.registerEvents()
|
||||||
Gamestate.switch(menu)
|
Gamestate.switch(menu)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- love callback will still be invoked
|
-- love callback will still be invoked
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
Timer.update(dt)
|
Timer.update(dt)
|
||||||
@ -346,4 +348,3 @@ This is by done by overwriting the love callbacks, e.g.::
|
|||||||
Gamestate.registerEvents{'draw', 'update', 'quit'}
|
Gamestate.registerEvents{'draw', 'update', 'quit'}
|
||||||
Gamestate.switch(menu)
|
Gamestate.switch(menu)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user