feat: add a special menu background

This commit is contained in:
Kazhnuz 2021-03-23 23:20:15 +01:00
parent 3335671a65
commit d6995ecbba
4 changed files with 51 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -0,0 +1,51 @@
local MenuBack = Object:extend()
function MenuBack:new()
self.backx = 0
self.bordery = 0
self.turn = 0
self.back = love.graphics.newImage("assets/gui/back/background.png")
self.border = love.graphics.newImage("assets/gui/back/border.png")
self.emblem = love.graphics.newImage("assets/gui/back/emblem.png")
self.canvas = nil
end
function MenuBack:update(dt)
self.backx = (self.backx + dt * 20) % 96
self.bordery = (self.bordery + dt * 35) % 160
self.turn = self.turn + (dt/1.5) % 1
self.canvas = love.graphics.newCanvas( 424, 240 )
love.graphics.setCanvas(self.canvas)
for i = 0, (math.ceil(424/96)), 1 do
for j = 0, (math.ceil(240/96)), 1 do
love.graphics.draw(self.back, self.backx + ((i - 1 ) * 96), self.backx + ((j - 1 ) * 96))
end
end
for j = 0, (math.ceil(240/160)), 1 do
love.graphics.draw(self.border, 0, self.bordery + ((j - 1) * 160))
end
love.graphics.draw(self.emblem, 424, 240 - 32, self.turn, 0.8, 0.8, 200, 200)
love.graphics.setColor(1, 1, 1, 0.85)
love.graphics.rectangle("fill", 0, 0, 424, 240)
love.graphics.setColor(1, 1, 1, 1)
love.graphics.setCanvas()
end
function MenuBack:draw()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.setBlendMode("multiply", "premultiplied")
if (self.canvas ~= nil) then
love.graphics.draw(self.canvas, 0, 0)
end
love.graphics.setBlendMode("alpha")
love.graphics.setColor(1, 1, 1, 1)
end
return MenuBack