Refonte pour utiliser le systeme de GUI #112
1 changed files with 19 additions and 11 deletions
|
@ -1,4 +1,9 @@
|
||||||
local MenuBack = Object:extend()
|
local TextureElement = require "birb.modules.gui.elements.parent"
|
||||||
|
local MenuBack = TextureElement:extend()
|
||||||
|
|
||||||
|
local backx = 0
|
||||||
|
local bordery = 0
|
||||||
|
local turn = 0
|
||||||
|
|
||||||
local fancyBackShader = love.graphics.newShader[[
|
local fancyBackShader = love.graphics.newShader[[
|
||||||
uniform number screenWidth;
|
uniform number screenWidth;
|
||||||
|
@ -13,52 +18,55 @@ local fancyBackShader = love.graphics.newShader[[
|
||||||
]]
|
]]
|
||||||
|
|
||||||
function MenuBack:new()
|
function MenuBack:new()
|
||||||
self.backx = 0
|
|
||||||
self.bordery = 0
|
|
||||||
self.turn = 0
|
|
||||||
self.back = love.graphics.newImage("assets/gui/back/background.png")
|
self.back = love.graphics.newImage("assets/gui/back/background.png")
|
||||||
self.border = love.graphics.newImage("assets/gui/back/border.png")
|
self.border = love.graphics.newImage("assets/gui/back/border.png")
|
||||||
self.emblem = love.graphics.newImage("assets/gui/back/emblem.png")
|
self.emblem = love.graphics.newImage("assets/gui/back/emblem.png")
|
||||||
self.star = love.graphics.newImage("assets/gui/back/star.png")
|
self.star = love.graphics.newImage("assets/gui/back/star.png")
|
||||||
|
self.backImage = love.graphics.newImage("assets/artworks/back.png")
|
||||||
|
|
||||||
self.canvas = nil
|
self.canvas = nil
|
||||||
local w, h = love.graphics.getDimensions()
|
local w, h = love.graphics.getDimensions()
|
||||||
fancyBackShader:send("screenWidth",w)
|
fancyBackShader:send("screenWidth",w)
|
||||||
fancyBackShader:send("screenHeight",h)
|
fancyBackShader:send("screenHeight",h)
|
||||||
|
MenuBack.super.new(self, "menuBack", 0, 0, w, h)
|
||||||
|
self.depth = 200
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function MenuBack:update(dt)
|
function MenuBack:update(dt)
|
||||||
self.backx = (self.backx + dt * 20) % 96
|
backx = (backx + dt * 20) % 96
|
||||||
self.bordery = (self.bordery + dt * 35) % 160
|
bordery = (bordery + dt * 35) % 160
|
||||||
self.turn = self.turn + (dt/1.5) % 1
|
turn = turn + (dt/1.5) % 1
|
||||||
|
|
||||||
self.canvas = love.graphics.newCanvas( 424, 240 )
|
self.canvas = love.graphics.newCanvas( 424, 240 )
|
||||||
love.graphics.setCanvas(self.canvas)
|
love.graphics.setCanvas(self.canvas)
|
||||||
for i = 0, (math.ceil(424/96)), 1 do
|
for i = 0, (math.ceil(424/96)), 1 do
|
||||||
for j = 0, (math.ceil(240/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))
|
love.graphics.draw(self.back, backx + ((i - 1 ) * 96), backx + ((j - 1 ) * 96))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for j = 0, (math.ceil(240/160)), 1 do
|
for j = 0, (math.ceil(240/160)), 1 do
|
||||||
love.graphics.draw(self.border, 0, self.bordery + ((j - 1) * 160))
|
love.graphics.draw(self.border, 0, bordery + ((j - 1) * 160))
|
||||||
end
|
end
|
||||||
love.graphics.draw(self.emblem, 424, 240 - 32, 0, 0.8, 0.8, 200, 200)
|
love.graphics.draw(self.emblem, 424, 240 - 32, 0, 0.8, 0.8, 200, 200)
|
||||||
love.graphics.draw(self.star, 424, 240 - 32, self.turn, 0.8, 0.8, 200, 200)
|
love.graphics.draw(self.star, 424, 240 - 32, turn, 0.8, 0.8, 200, 200)
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
|
||||||
love.graphics.setCanvas()
|
love.graphics.setCanvas()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function MenuBack:draw()
|
function MenuBack:draw()
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
love.graphics.rectangle("fill", 0, 0, 424, 240)
|
||||||
love.graphics.setShader(fancyBackShader)
|
love.graphics.setShader(fancyBackShader)
|
||||||
if (self.canvas ~= nil) then
|
if (self.canvas ~= nil) then
|
||||||
love.graphics.draw(self.canvas, 0, 0)
|
love.graphics.draw(self.canvas, 0, 0)
|
||||||
end
|
end
|
||||||
love.graphics.setShader()
|
love.graphics.setShader()
|
||||||
|
utils.graphics.resetColor()
|
||||||
|
love.graphics.draw(self.backImage, 0, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
return MenuBack
|
return MenuBack
|
Loading…
Reference in a new issue