Love:Mike: Timer now saves/loads
This commit is contained in:
parent
263c8fa952
commit
e5ef06f61a
@ -25,6 +25,8 @@ function love.keyreleased(key)
|
|||||||
if save_exists then
|
if save_exists then
|
||||||
--player = Tserial.unpack( love.filesystem.read( saveFile ) )
|
--player = Tserial.unpack( love.filesystem.read( saveFile ) )
|
||||||
actors = GameState.load(SAVE_FILE)
|
actors = GameState.load(SAVE_FILE)
|
||||||
|
-- Tell the timer to ignore time passed between the save and the load
|
||||||
|
actors.start = love.timer.getTime() - actors.end_timer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -22,13 +22,13 @@ function love.load()
|
|||||||
|
|
||||||
|
|
||||||
actors.start = love.timer.getTime()
|
actors.start = love.timer.getTime()
|
||||||
local end_timer = 0
|
actors.end_timer = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
actors.player = check_keys(actors.player, screen, dt)
|
actors.player = check_keys(actors.player, screen, dt)
|
||||||
actors.ball = ball_bounce(actors.player, actors.ball, dt)
|
actors.ball = ball_bounce(actors.player, actors.ball, dt)
|
||||||
end_timer = love.timer.getTime() - actors.start
|
actors.end_timer = love.timer.getTime() - actors.start
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
@ -48,6 +48,6 @@ function love.draw()
|
|||||||
love.graphics.print("Score: "..actors.ball.score, screen.width -80, 10)
|
love.graphics.print("Score: "..actors.ball.score, screen.width -80, 10)
|
||||||
--Timer
|
--Timer
|
||||||
love.graphics.setColor(125,42,19)
|
love.graphics.setColor(125,42,19)
|
||||||
love.graphics.print(string.format("Time M: %.2f", end_timer/60), screen.width -85, 50)
|
love.graphics.print(string.format("Time M: %.2f", actors.end_timer/60), screen.width -85, 50)
|
||||||
love.graphics.print(string.format("Time S: %.2f", end_timer), screen.width -85, 30)
|
love.graphics.print(string.format("Time S: %.2f", actors.end_timer), screen.width -85, 30)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user