Love:Mike: Timer now saves/loads

This commit is contained in:
Logen Kain 2017-08-10 10:16:18 -07:00
parent 263c8fa952
commit e5ef06f61a
2 changed files with 6 additions and 4 deletions

View File

@ -25,6 +25,8 @@ function love.keyreleased(key)
if save_exists then
--player = Tserial.unpack( love.filesystem.read( saveFile ) )
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

View File

@ -22,13 +22,13 @@ function love.load()
actors.start = love.timer.getTime()
local end_timer = 0
actors.end_timer = 0
end
function love.update(dt)
actors.player = check_keys(actors.player, screen, 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
function love.draw()
@ -48,6 +48,6 @@ function love.draw()
love.graphics.print("Score: "..actors.ball.score, screen.width -80, 10)
--Timer
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 S: %.2f", end_timer), screen.width -85, 30)
love.graphics.print(string.format("Time M: %.2f", actors.end_timer/60), screen.width -85, 50)
love.graphics.print(string.format("Time S: %.2f", actors.end_timer), screen.width -85, 30)
end