Blame view

game/scene6.lua 4.33 KB
ca0e8212   Geoffrey PREUD'HOMME   Code original
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  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

175e3cfa   Geoffrey PREUD'HOMME   Arrêt après fin
25
      ended = false

ca0e8212   Geoffrey PREUD'HOMME   Code original
26
27
28
29
30
31
32
33
34
35
36
  	

  	playerx = playerx or 50

  	landingx = landingx or 50

  	

  	landdiff = playerx-landingx

  	

  	scoremul = round((1-math.abs(landdiff)/80)^8*4, 1) + 1

  	

  	stars = {}

  	

  	texts = {}

57f5b105   Geoffrey PREUD'HOMME   Tout traduit en f...
37
  	texts[1] = "ton super score:"

ca0e8212   Geoffrey PREUD'HOMME   Code original
38
39
  	texts[2] = points

  	texts[3] = ""

57f5b105   Geoffrey PREUD'HOMME   Tout traduit en f...
40
  	texts[4] = "multiplicateur de cible:"

ca0e8212   Geoffrey PREUD'HOMME   Code original
41
42
  	texts[5] = scoremul

  	texts[6] = ""

57f5b105   Geoffrey PREUD'HOMME   Tout traduit en f...
43
  	texts[7] = "mega total:"

ca0e8212   Geoffrey PREUD'HOMME   Code original
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
  	texts[8] = math.ceil(points*scoremul)

  	

  	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

175e3cfa   Geoffrey PREUD'HOMME   Arrêt après fin
107
  

ca0e8212   Geoffrey PREUD'HOMME   Code original
108
  	if starttimer >= 15.7 and starttimer -dt < 15.7 then

175e3cfa   Geoffrey PREUD'HOMME   Arrêt après fin
109
110
          print(string.format("SCORE:%d", math.ceil(points*scoremul)));

          ended = true

ca0e8212   Geoffrey PREUD'HOMME   Code original
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
  		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

  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

175e3cfa   Geoffrey PREUD'HOMME   Arrêt après fin
177
178
179
180
181
182
183
184
185
186
  

      if ended and starttimer % (5/12) > (5/24) then

          properprint("appuie sur espace pour recommencer", 15, 50, scale/4);

      end

  end

  

  function scene6_keypressed(key, unicode)

      if ended then

          love.event.quit()

      end

57f5b105   Geoffrey PREUD'HOMME   Tout traduit en f...
187
  end