-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathendscene.lua
More file actions
57 lines (44 loc) · 1.69 KB
/
Copy pathendscene.lua
File metadata and controls
57 lines (44 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
local Object = require 'libs/classic/classic'
EndScene = Object:extend()
function EndScene:new(team)
if team == "Jogador" then
self.message = "Parabéns, você venceu e mostrou quem manda!"
self.background = love.graphics.newImage('assets/images/bg_intro.png')
else
self.message = "Deu ruim, campeão. Só te resta a carreira de empreendedor de palco."
self.background = love.graphics.newImage('assets/images/bg_defeat.png')
end
self.team = team
end
function EndScene:init()
self.keystrokeCount = 0
end
function EndScene:update(dt)
end
function EndScene:draw(ox, oy)
local scaleFactor = settings:screenScaleFactor()
local messageFont = assets.fonts.pressstartregular(assets.config.fonts.creditsTextSize * scaleFactor)
local oldFont = love.graphics.getFont()
local r, g, b, a = love.graphics.getColor()
local scaleX = love.graphics.getWidth() / self.background:getWidth()
local scaleY = love.graphics.getHeight() / self.background:getHeight()
love.graphics.draw(self.background, 0, 0, 0, scaleX, scaleY)
local titleWidth = love.graphics.getWidth() * .6
local titleX = (love.graphics.getWidth()/2) - (titleWidth/2)
local titleY = love.graphics.getHeight() * 0.4
love.graphics.setColor(0,0,0,255)
love.graphics.setFont(messageFont)
love.graphics.printf(self.message, titleX, titleY, titleWidth)
-- restore old graphic settings --
love.graphics.setFont(oldFont)
love.graphics.setColor(r,g,b,a)
end
function EndScene:keyPressed(key, scancode, isRepeat)
if not isRepeat then
self.keystrokeCount = self.keystrokeCount + 1
end
if (self.keystrokeCount == 2) then
sceneManager:popScene()
end
end
return EndScene