From d7c6a00da449c6f7d195758e70e355f89db451a3 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 14 Jan 2017 16:51:07 +0100 Subject: Fixed crash when switching from match to menu --- menu.lua | 16 ++++++++++++---- 1 file 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 -- cgit v1.1