scene6.lua
4.22 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
function scene6_load()
love.graphics.setBackgroundColor(153, 217, 234)
love.audio.stop(bgmusic)
clouds2 = {}
clouds = {}
bushes = {}
bigexplosions = {}
playerquad = 1
if sunglasses then
playerquad = 3
end
playeranimationtimer = 0
starttimer = 0
birds = {}
splatters = {}
shakeamount = 10
fade = 0
ended = false
playerx = playerx or 50
landingx = landingx or 50
landdiff = playerx-landingx
scoremul = round((1-math.abs(landdiff)/80)^8*4, 1) + 1
scoretot = math.ceil(points*scoremul)
stars = {}
texts = {}
texts[1] = "ton super score:"
texts[2] = points
texts[3] = ""
texts[4] = "multiplicateur de cible:"
texts[5] = scoremul
texts[6] = ""
texts[7] = "mega total:"
texts[8] = scoretot
prevt = 0
to = 0
totimes = {8.55, 8.8, 9.4, 9.5, 9.7, 11.0, 12.3, 12.9, 13.2}
end
function scene6_update(dt)
playeranimationtimer = playeranimationtimer + dt
while playeranimationtimer > 0.1 do
playeranimationtimer = playeranimationtimer - 0.1
playerquad = playerquad + 1
if playerquad == 3 then
playerquad = 1
elseif playerquad == 5 then
playerquad = 3
end
end
for i, v in pairs(bigexplosions) do
v:update(dt)
end
if starttimer >= 0.7 and starttimer - dt < 0.7 then
bigexplosionsound:play()
end
if starttimer < 0.2 then
elseif starttimer < 0.5 then
fade = 1
if #explosions == 0 then
table.insert(bigexplosions, bigexplosion:new(-4, -30))
table.insert(bigexplosions, bigexplosion:new(-40, -30))
table.insert(bigexplosions, bigexplosion:new(36, -30))
table.insert(bigexplosions, bigexplosion:new(-4, -50))
end
elseif starttimer < 4 then
if fade > 0.5 then
fade = fade - dt/2
end
else
if fade > 0 then
fade = fade - dt/2
end
end
if starttimer > 8.3 and starttimer - dt < 8.3 then
credits:play()
end
if shakeamount > 0 then
shakeamount = shakeamount - dt*3
end
for i = 1, 9 do
if starttimer > totimes[i] then
to = i
end
end
if starttimer >= 15.7 and starttimer -dt < 15.7 then
print("SCORE:" .. scoretot .. ":" .. pseudo)
ended = true
staralpha = 1
stars = {}
love.graphics.setBackgroundColor(0, 0, 0)
for i = 1, 10 do
table.insert(stars, star:new())
end
end
for i,v in pairs(stars) do
v:update(dt)
end
if starttimer >= 20 and starttimer -dt < 20 then
changegamestate("menu")
credits:pause()
end
end
function scene6_draw()
local r, g, b = love.graphics.getColor()
for i = 1, backgroundstripes, 1 do
if math.mod(i, 2) == 1 then
love.graphics.setColor(255, 255, 0, math.min(1, math.max(0, 1-(starttimer-7)/2))*255)
else
love.graphics.setColor(255, 0, 0, math.min(1, math.max(0, 1-(starttimer-7)/2))*255)
end
local pos = {31, 53}
local alpha = math.rad((i/backgroundstripes + math.mod(sunrot/100, 1)) * 360)
local point1 = {pos[1]*scale+200*scale*math.cos(alpha), pos[2]*scale+200*scale*math.sin(alpha)}
local alpha = math.rad(((i+1)/backgroundstripes + math.mod(sunrot/100, 1)) * 360)
local point2 = {pos[1]*scale+200*scale*math.cos(alpha), pos[2]*scale+200*scale*math.sin(alpha)}
love.graphics.polygon("fill", pos[1]*scale, pos[2]*scale, point1[1], point1[2], point2[1], point2[2])
end
love.graphics.setColor(r, g, b, 255)
for i,v in pairs(stars) do
v:draw()
v:draw()
v:draw()
v:draw()
end
love.graphics.translate(20*scale, 50*scale)
love.graphics.rotate(math.pi/7)
love.graphics.translate(-20*scale, -50*scale)
for i, v in pairs(bigexplosions) do
v:draw()
end
draw(groundwinimg, -168-landdiff, 56)
love.graphics.drawq(winplayerimg, winplayerquad[playerquad], 30*scale, 55*scale, 0, scale, scale, 5, 13)
love.graphics.translate(20*scale, 50*scale)
love.graphics.rotate(-math.pi/7)
love.graphics.translate(-20*scale, -50*scale)
for i = 1, math.min(9, to) do
local s = scale/2
if i >= 8 then
s = s * 2
love.graphics.setColor(getrainbowcolor(math.random()))
end
if i == 9 then
draw(titleimg, 65, 65, 0, 0.7, 0.7, 50, 14)
else
properprint(texts[i], 50-tostring(texts[i]):len()*s/2, 5*i, s)
end
love.graphics.setColor(255, 255, 255)
end
end