2021-08-26 23:27:43 +02:00
|
|
|
local TextureElement = require "birb.modules.gui.elements.parent"
|
|
|
|
local MenuBack = TextureElement:extend()
|
|
|
|
|
|
|
|
local backx = 0
|
|
|
|
local bordery = 0
|
|
|
|
local turn = 0
|
2021-03-23 23:20:15 +01:00
|
|
|
|
2021-04-04 13:17:12 +02:00
|
|
|
local fancyBackShader = love.graphics.newShader[[
|
|
|
|
uniform number screenWidth;
|
|
|
|
uniform number screenHeight;
|
|
|
|
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
|
|
|
|
vec4 pixel = Texel(texture, texture_coords); //This is the current pixel color
|
|
|
|
number value = (screen_coords.x / screenWidth) * (screen_coords.y / screenHeight) * 0.5;
|
|
|
|
number lighten = 0.25;
|
|
|
|
return vec4(0.5 + value + lighten,0.0 + lighten,0.5 - value + lighten, 1 - pixel.r);
|
|
|
|
//return vec4(1,1,1, pixel.r);
|
|
|
|
}
|
|
|
|
]]
|
|
|
|
|
2021-03-23 23:20:15 +01:00
|
|
|
function MenuBack:new()
|
|
|
|
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")
|
2021-04-04 13:17:12 +02:00
|
|
|
self.star = love.graphics.newImage("assets/gui/back/star.png")
|
2021-08-26 23:27:43 +02:00
|
|
|
self.backImage = love.graphics.newImage("assets/artworks/back.png")
|
2021-03-23 23:20:15 +01:00
|
|
|
|
|
|
|
self.canvas = nil
|
2021-04-04 13:17:12 +02:00
|
|
|
local w, h = love.graphics.getDimensions()
|
|
|
|
fancyBackShader:send("screenWidth",w)
|
|
|
|
fancyBackShader:send("screenHeight",h)
|
2021-08-26 23:27:43 +02:00
|
|
|
MenuBack.super.new(self, "menuBack", 0, 0, w, h)
|
|
|
|
self.depth = 200
|
2021-03-23 23:20:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function MenuBack:update(dt)
|
2021-08-26 23:27:43 +02:00
|
|
|
backx = (backx + dt * 20) % 96
|
|
|
|
bordery = (bordery + dt * 35) % 160
|
|
|
|
turn = turn + (dt/1.5) % 1
|
2021-03-23 23:20:15 +01:00
|
|
|
|
|
|
|
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
|
2021-08-26 23:27:43 +02:00
|
|
|
love.graphics.draw(self.back, backx + ((i - 1 ) * 96), backx + ((j - 1 ) * 96))
|
2021-03-23 23:20:15 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for j = 0, (math.ceil(240/160)), 1 do
|
2021-08-26 23:27:43 +02:00
|
|
|
love.graphics.draw(self.border, 0, bordery + ((j - 1) * 160))
|
2021-03-23 23:20:15 +01:00
|
|
|
end
|
2021-04-04 13:17:12 +02:00
|
|
|
love.graphics.draw(self.emblem, 424, 240 - 32, 0, 0.8, 0.8, 200, 200)
|
2021-08-26 23:27:43 +02:00
|
|
|
love.graphics.draw(self.star, 424, 240 - 32, turn, 0.8, 0.8, 200, 200)
|
2021-03-23 23:20:15 +01:00
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
|
|
|
|
love.graphics.setCanvas()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function MenuBack:draw()
|
2021-08-26 23:27:43 +02:00
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
love.graphics.rectangle("fill", 0, 0, 424, 240)
|
2021-04-04 13:17:12 +02:00
|
|
|
love.graphics.setShader(fancyBackShader)
|
2021-03-23 23:20:15 +01:00
|
|
|
if (self.canvas ~= nil) then
|
|
|
|
love.graphics.draw(self.canvas, 0, 0)
|
|
|
|
end
|
2021-04-04 13:17:12 +02:00
|
|
|
love.graphics.setShader()
|
2021-08-26 23:27:43 +02:00
|
|
|
utils.graphics.resetColor()
|
|
|
|
love.graphics.draw(self.backImage, 0, 0)
|
2021-03-23 23:20:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
return MenuBack
|