-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgameOver.lua
106 lines (75 loc) · 3.08 KB
/
gameOver.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
local moonshine = require ("moonshine")
local Text = require("text")
require("utils")
gameOverScreen = {
gameOverText = {}
}
local effect
gameOverScreen.load = function ()
local textOffset = 5
local textScale = 1.7
gameOverScreen.gameOverText = {
Text:new("G", 0 , 0 ,textScale),
Text:new("A", 1 * textOffset * GRIDSIZE , 0,textScale),
Text:new("M", 2 * textOffset * GRIDSIZE, 0,textScale),
Text:new("E", 3 * textOffset * GRIDSIZE, 0,textScale),
Text:new("O", 0 * textOffset * GRIDSIZE, 5 * GRIDSIZE,textScale),
Text:new("V", 1 * textOffset * GRIDSIZE,5 * GRIDSIZE,textScale),
Text:new("R", 2 * textOffset * GRIDSIZE,5 * GRIDSIZE,textScale),
Text:new("E", 3 * textOffset * GRIDSIZE,5 * GRIDSIZE,textScale),
}
textScale = 0.8
local restartText = Text:new("Restart", GRIDSIZE * 10 , 5 * GRIDSIZE + (HEIGHT - 3 * textOffset) * GRIDSIZE ,textScale)
local backText = Text:new("Back" , GRIDSIZE * 10 , 10 * GRIDSIZE + (HEIGHT - 3 * textOffset) * GRIDSIZE ,textScale)
restartText.onClick = function () Screen.selectScreen(2) end
backText.onClick = function () Screen.selectScreen(1) end
restartText.color = {0.5,1,0.5,1}
backText.color = {1,1,0,1}
gameOverScreen.btns = {restartText,backText}
effect = moonshine(moonshine.effects.glow)
effect.glow.strength = 2
end
gameOverScreen.update = function ()
for i = 1 ,#gameOverScreen.gameOverText do
gameOverScreen.gameOverText[i]:setY((math.sin(love.timer.getTime() * 3 + (i - 1) * GRIDSIZE ) * 10 + gameOverScreen.gameOverText[i].defaulY))
end
for i = 1, #gameOverScreen.btns do
gameOverScreen.btns[i]:update()
end
for i = 1, #gameOverScreen.btns do
if gameOverScreen.btns[i].hoverOver then
isHand = true
if love.mouse.isDown(1) then
gameOverScreen.btns[i].onClick()
end
gameOverScreen.btns[i]:setX(gameOverScreen.btns[i].defaulX + math.sin(love.timer.getTime() * 100) * 2 )
else
gameOverScreen.btns[i]:setX(gameOverScreen.btns[i].defaulX)
end
end
end
gameOverScreen.draw = function ()
for i = 1, #gameOverScreen.btns do
if gameOverScreen.btns[i].hoverOver then
love.graphics.setColor(gameOverScreen.btns[i].color[1],gameOverScreen.btns[i].color[2],gameOverScreen.btns[i].color[3],gameOverScreen.btns[i].color[4])
effect(function ()
gameOverScreen.btns[i]:draw()
end)
else
gameOverScreen.btns[i]:draw()
end
love.graphics.setColor(1,1,1,1)
end
love.graphics.setColor(1,1 ,1,1)
love.graphics.push()
love.graphics.translate(GRIDSIZE * 6,GRIDSIZE / 2 )
effect(function ()
for i = 1, #gameOverScreen.gameOverText do
gameOverScreen.gameOverText[i]:draw()
end
love.graphics.setColor(1,1,1,1)
love.graphics.pop()
end)
end
gameOverScreen.events = function (key, scancode, isrepeat)
end