-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameinfo.lua
76 lines (68 loc) · 1.69 KB
/
gameinfo.lua
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
GameInfoDisplayer = {}
function GameInfoDisplayer:new(game,mode)
local o = clone(self)
o.game = game
o.scoreText = AniText:new()
o.levelText = AniText:new()
o.mode = mode
return o
end
function GameInfoDisplayer:draw()
self:drawBackground()
self:drawPreviews()
self:drawSpecial()
self:drawText()
end
function GameInfoDisplayer:drawBackground()
love.graphics.clear(0x00,0x00,0x00,000)
love.graphics.setColor(255,255,255,255)
love.graphics.draw(GAMEBACKGROUND)
love.graphics.draw(MODEIMAGE[self.mode])
end
function GameInfoDisplayer:drawPreviews()
for p=1,#PREVIEWS do
setColor("background")
preview = PREVIEWS[p]
love.graphics.rectangle('fill',unpack(preview))
piece = self.game.pieces[p]
w,h = preview[3]/2,preview[4]/2
for i=1,2 do
for j=1,2 do
x,y = preview[1]+(2-j)*w,preview[2]+(2-i)*h
setColor(piece.shape[i][j])
love.graphics.rectangle('fill',
x+PREVIEW_INDENT[i][j][1],
y+PREVIEW_INDENT[i][j][2],
w-PREVIEW_INDENT[i][j][3],
h-PREVIEW_INDENT[i][j][4]
)
end
end
end
end
function GameInfoDisplayer:drawSpecial()
love.graphics.setColor(COLORS["special-back"])
love.graphics.rectangle('fill',unpack(SPECIAL_POS))
love.graphics.setColor(COLORS["special"])
love.graphics.rectangle(
'fill',
SPECIAL_POS[1],
SPECIAL_POS[2],
SPECIAL_POS[3]*self.game.special/REMOVE_COLOR_COST,
SPECIAL_POS[4]
)
love.graphics.draw(
SPECIALIMAGE,
SPECIAL_POS[1],
SPECIAL_POS[2]
)
end
function GameInfoDisplayer:drawText()
love.graphics.setColor(255,255,255)
self.scoreText:draw(self.game.score, 781, 437)
self.levelText:draw(self.game.level, 784, 780)
end
function GameInfoDisplayer:update(dt)
self.scoreText:update(dt)
self.levelText:update(dt)
end