summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-01-14 16:51:07 +0100
committerAki <nthirtyone@gmail.com>2017-01-14 16:51:07 +0100
commitd7c6a00da449c6f7d195758e70e355f89db451a3 (patch)
tree84259a3fedeeb87f767b5d7b81e6c72b2ca3caf2
parentb3f37fbf88e691425ff04cdeb942dda693f6e14e (diff)
downloadroflnauts-d7c6a00da449c6f7d195758e70e355f89db451a3.zip
roflnauts-d7c6a00da449c6f7d195758e70e355f89db451a3.tar.gz
roflnauts-d7c6a00da449c6f7d195758e70e355f89db451a3.tar.bz2
Fixed crash when switching from match to menu
-rw-r--r--menu.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/menu.lua b/menu.lua
index 36e06ef..fef46df 100644
--- a/menu.lua
+++ b/menu.lua
@@ -15,7 +15,8 @@ Menu = {
asteroids,
stars,
asteroids_bounce = 0,
- stars_timer = 0,
+ stars_frame = 1,
+ stars_delay = 0.8,
allowMove = true,
quads = {
button = {
@@ -96,14 +97,21 @@ function Menu:update(dt)
end
self.asteroids_bounce = self.asteroids_bounce + dt*0.1
if self.asteroids_bounce > 2 then self.asteroids_bounce = self.asteroids_bounce - 2 end
- self.stars_timer = self.stars_timer + dt * 0.7
- if self.stars_timer > 2 then self.stars_timer = self.stars_timer - 2 end
+ self.stars_delay = self.stars_delay - dt
+ if self.stars_delay < 0 then
+ self.stars_delay = self.stars_delay + Menu.stars_delay --Menu.stars_delay is initial
+ if self.stars_frame == 2 then
+ self.stars_frame = 1
+ else
+ self.stars_frame = 2
+ end
+ end
end
function Menu:draw()
local scale = self.scale
local scaler = getRealScale()
love.graphics.draw(self.background, 0, 0, 0, scaler, scaler)
- love.graphics.draw(self.stars, self.quads.stars[math.ceil(self.stars_timer)], 0, 0, 0, scaler, scaler)
+ love.graphics.draw(self.stars, self.quads.stars[self.stars_frame], 0, 0, 0, scaler, scaler)
love.graphics.draw(self.asteroids, 0, math.floor(64+math.sin(self.asteroids_bounce*math.pi)*4)*scaler, 0, scaler, scaler)
love.graphics.setFont(Font)
for _,element in pairs(self.elements) do