diff options
author | Aki <nthirtyone@gmail.com> | 2017-01-13 20:43:51 +0100 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-01-13 20:43:51 +0100 |
commit | 327ebbf23e19828fb6779607e2364b8b76ba627c (patch) | |
tree | 8a0e6932f7c622b29c6e1face32b903c9179996e | |
parent | 5a1c5fec6412520616f111ae850c9a9c5e1a256d (diff) | |
download | roflnauts-327ebbf23e19828fb6779607e2364b8b76ba627c.zip roflnauts-327ebbf23e19828fb6779607e2364b8b76ba627c.tar.gz roflnauts-327ebbf23e19828fb6779607e2364b8b76ba627c.tar.bz2 |
Menu background animation
-rw-r--r-- | assets/asteroids.png | bin | 0 -> 1227 bytes | |||
-rw-r--r-- | assets/backgrounds/menu.png | bin | 13640 -> 11447 bytes | |||
-rw-r--r-- | assets/stars.png | bin | 0 -> 1644 bytes | |||
-rw-r--r-- | menu.lua | 19 |
4 files changed, 18 insertions, 1 deletions
diff --git a/assets/asteroids.png b/assets/asteroids.png Binary files differnew file mode 100644 index 0000000..cb85a2b --- /dev/null +++ b/assets/asteroids.png diff --git a/assets/backgrounds/menu.png b/assets/backgrounds/menu.png Binary files differindex 9be3233..b42f8f6 100644 --- a/assets/backgrounds/menu.png +++ b/assets/backgrounds/menu.png diff --git a/assets/stars.png b/assets/stars.png Binary files differnew file mode 100644 index 0000000..4965389 --- /dev/null +++ b/assets/stars.png @@ -12,6 +12,10 @@ Menu = { music, sprite, background, + asteroids, + stars, + asteroids_bounce = 0, + stars_timer = 0, allowMove = true, quads = { button = { @@ -28,6 +32,10 @@ Menu = { }, arrow_l = love.graphics.newQuad(68, 0, 6, 6, 80,130), arrow_r = love.graphics.newQuad(74, 0, 6, 6, 80,130), + stars = { + love.graphics.newQuad( 0, 0, 320, 200, 640,200), + love.graphics.newQuad(320, 0, 320, 200, 640,200) + }, } } function Menu:new(name) @@ -36,6 +44,8 @@ function Menu:new(name) self.__index = self self.sprite = love.graphics.newImage("assets/menu.png") self.background = love.graphics.newImage("assets/backgrounds/menu.png") + self.asteroids = love.graphics.newImage("assets/asteroids.png") + self.stars = love.graphics.newImage("assets/stars.png") o.elements = {} o:load(name) o.music = Music:new("menu.ogg") @@ -84,10 +94,17 @@ function Menu:update(dt) for _,element in pairs(self.elements) do element: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 end function Menu:draw() local scale = self.scale - love.graphics.draw(self.background, 0, 0, 0, getRealScale(), getRealScale()) + 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.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 element:draw(scale) |