scene5.lua
5.08 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
function scene5_load()
love.graphics.setBackgroundColor(153, 217, 234)
love.audio.play(bgmusic)
clouds2 = {}
for i = 1, 3 do
for y = 1, 8 do
table.insert(clouds2, cloud2:new(math.random()*140))
end
end
lastexplosion = {50, 40}
starttimer = 0
flyingquad = 3
playerx = 50
playery = 20
pspeedx = 0
pspeedy = 0
birds = {}
splatters = {}
birdtimer = 0
flyanimationtimer = 0
shakeamount = 5
awesometimer = 0
screenx = 0
landingtime = 2
groundy = 90
landing = false
end
function scene5_update(dt)
if starttimer < 20 then
birdtimer = birdtimer + dt
local birddelay = 0.5
while birdtimer > birddelay do
birdtimer = birdtimer - birddelay
table.insert(birds, bird:new())
end
end
if starttimer >= 25 and starttimer - dt < 25 then
landing = true
timeleft = landingtime
landingx = math.random(60)+20
end
if starttimer >= 25.4 and starttimer - dt < 25.4 then
approach:play()
end
if landing then
timeleft = timeleft - dt
if timeleft <= 0 then
timeleft = 0
groundy = groundy - 400*dt
if groundy <= playery-10 then
changegamestate("scene6")
end
end
end
for i,v in pairs(clouds2) do
v:update(dt)
end
flyanimationtimer = flyanimationtimer + dt
while flyanimationtimer > 0.1 do
flyanimationtimer = flyanimationtimer - 0.1
if flyingquad == 3 then
flyingquad = 4
else
flyingquad = 3
end
end
if awesometimer > 0 then
awesometimer = awesometimer - dt
end
if landing or starttimer < 24 then
playermovement2(dt)
else
if playerx > 50 then
playerx = playerx - 50*dt
elseif playerx < 50 then
playerx = playerx + 50*dt
end
if playery > 40 then
playery = playery - 50*dt
elseif playery < 40 then
playery = playery + 50*dt
end
end
--BIRDS
local delete = {}
for i, v in pairs(birds) do
if v:update(dt) == true then
table.insert(delete, i)
end
end
table.sort(delete, function(a,b) return a>b end)
for i, v in pairs(delete) do
table.remove(birds, v) --remove
end
--SPLATTERS
local delete = {}
for i, v in pairs(splatters) do
if v:update(dt) == true then
table.insert(delete, i)
end
end
table.sort(delete, function(a,b) return a>b end)
for i, v in pairs(delete) do
table.remove(splatters, v) --remove
end
for i, v in pairs(birds) do
if v:checkcol(playerx, playery) then
splat:stop()
splat:play()
pointsget(20)
table.insert(splatters, splatter:new(v.x, v.y))
skycolor = getrainbowcolor(math.random(), 400)
love.graphics.setBackgroundColor(skycolor)
lastexplosion = {v.x, v.y}
end
end
end
function playermovement2(dt)
if love.keyboard.isDown("left") then
playerx = math.max(0, playerx-dt*movement1speed)
elseif love.keyboard.isDown("right") then
playerx = math.min(100, playerx+dt*movement1speed)
end
if not landing then
if love.keyboard.isDown("up") then
playery = math.max(0, playery-dt*movement1speed)
elseif love.keyboard.isDown("down") then
playery = math.min(80, playery+dt*movement1speed)
end
end
end
function scene5_draw()
local r, g, b = love.graphics.getColor()
love.graphics.setColor(math.random(255), math.random(255), math.random(255), 100*math.min(1, (starttimer/2)))
for i = 1, backgroundstripes, 2 do
local pos = {playerx, playery}
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(clouds2) do
v:draw()
end
for i,v in pairs(birds) do
v:draw()
end
for i,v in pairs(splatters) do
v:draw()
end
if groundy < 90 then
draw(groundwinimg, -200+landingx+2, groundy)
end
love.graphics.drawq(playerimg, playerquad[flyingquad], (playerx)*scale, playery*scale, 0, scale, scale, 13, 6)
if sunglasses then
draw(sunglassesimg, playerx+4, playery)
end
if awesometimer > 0 then
draw(awesomeimg, (awesometimer*2-1)*100, 0)
love.graphics.setColor(0, 0, 0)
properprint("1000 points!", (awesometimer*2-1)*100+3, 73, scale)
love.graphics.setColor(255, 255, 255)
end
if starttimer > 24 then
if math.mod(starttimer*5, 2) >= 1 then
love.graphics.setColor(255, 0, 0)
properprint("atteri sur la cible !", 0, 20, scale/1.5)
love.graphics.setColor(255, 255, 255)
end
end
if landing then
draw(arrowimg, math.max(8, landingx-(timeleft/landingtime)*80), 67, 0, 1, 1, 8)
draw(arrowimg, math.min(91, landingx+(timeleft/landingtime)*80), 67, 0, -1, 1, 9)
end
end
function scene5_action()
if not sunglasses then
sunglasses = true
awesometimer = 1
pointsget(1000)
sunglassessound:play()
end
end