1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using Jypeli; |
---|
4 | using Jypeli.ScreenObjects; |
---|
5 | using Jypeli.Assets; |
---|
6 | using Jypeli.Widgets; |
---|
7 | using Jypeli.Effects; |
---|
8 | using Physics2DDotNet.Ignorers; |
---|
9 | |
---|
10 | public class Peli : PhysicsGame |
---|
11 | { |
---|
12 | Vector nopeusYlos = new Vector(0, 600); |
---|
13 | Vector nopeusAlas = new Vector(0, -600); |
---|
14 | //public enum mahdollisetX {Level.Left, Level.Right} |
---|
15 | |
---|
16 | List<String> powerUpit; |
---|
17 | |
---|
18 | ExplosionSystem rajahdys; |
---|
19 | Flames liekki; |
---|
20 | |
---|
21 | PhysicsObject pallo; |
---|
22 | |
---|
23 | PhysicsObject maila1; |
---|
24 | PhysicsObject maila2; |
---|
25 | PhysicsObject kummallaMagneettiPowerup; |
---|
26 | |
---|
27 | IntMeter pelaajan1Pisteet; |
---|
28 | IntMeter pelaajan2Pisteet; |
---|
29 | |
---|
30 | GameObject pelaajan1PowerUpNaytto; |
---|
31 | GameObject pelaajan2PowerUpNaytto; |
---|
32 | |
---|
33 | PhysicsObject vasenReuna; |
---|
34 | PhysicsObject oikeaReuna; |
---|
35 | PhysicsObject ylinReuna; |
---|
36 | PhysicsObject alaReuna; |
---|
37 | |
---|
38 | ObjectIgnorer ignorer; |
---|
39 | |
---|
40 | |
---|
41 | const double pallonNopeus = 500; |
---|
42 | Image powerupKuva1 = LoadImage("mushroom2"); |
---|
43 | Image powerupKuva2 = LoadImage("powerstar"); |
---|
44 | |
---|
45 | SoundEffect OsumaAani; |
---|
46 | |
---|
47 | Timer powerUpAjastin; |
---|
48 | Image pallonKuva = LoadImage("trollface"); |
---|
49 | bool pallonPitaaLiikkua; //totuusarvo, joko true tai false |
---|
50 | bool magneettiPowerUpAktiivisena; |
---|
51 | |
---|
52 | protected override void Begin() |
---|
53 | { |
---|
54 | OsumaAani = LoadSoundEffect("smw_coin"); |
---|
55 | ignorer = new ObjectIgnorer(); |
---|
56 | LuoKentta(); |
---|
57 | AsetaOhjaimet(); |
---|
58 | LisaaLaskurit(); |
---|
59 | LisaaAjastimet(); |
---|
60 | LisaaPowerUpit(); |
---|
61 | AloitaPeli(); |
---|
62 | } |
---|
63 | |
---|
64 | void LisaaPowerUpit() |
---|
65 | { |
---|
66 | powerUpit = new List<String>(); |
---|
67 | powerUpit.Add("magneetti"); |
---|
68 | powerUpit.Add("vaihdasuuntaa"); |
---|
69 | } |
---|
70 | |
---|
71 | PhysicsObject SatunnainenPowerup() |
---|
72 | { |
---|
73 | String powerupNimi = powerUpit[RandomGen.NextInt(0, powerUpit.Count - 1)]; |
---|
74 | PhysicsObject powerup = UusiPowerup(powerupNimi, Shapes.Circle, powerupKuva1, 16.0); |
---|
75 | switch (powerupNimi) |
---|
76 | { |
---|
77 | case "magneetti": |
---|
78 | return powerup; |
---|
79 | case "vaihdasuuntaa": |
---|
80 | return (UusiPowerup(powerupNimi, Shapes.Circle, powerupKuva2, 16.0)); |
---|
81 | } |
---|
82 | return powerup; |
---|
83 | } |
---|
84 | |
---|
85 | private PhysicsObject UusiPowerup(string nimi, Shape muoto, Image kuva, double koko) |
---|
86 | { |
---|
87 | PhysicsObject powerup = new PhysicsObject(koko, koko); |
---|
88 | powerup.Shape = muoto; |
---|
89 | powerup.Image = kuva; |
---|
90 | powerup.Tag = nimi; |
---|
91 | return powerup; |
---|
92 | } |
---|
93 | |
---|
94 | void LisaaPowerupKentalle(Timer ajastin) |
---|
95 | { |
---|
96 | PhysicsObject powerup = SatunnainenPowerup(); |
---|
97 | |
---|
98 | int kumpi = RandomGen.NextInt(0, 1); |
---|
99 | switch (kumpi) |
---|
100 | { |
---|
101 | case 0: |
---|
102 | // poweruppi tulee vasemmalle |
---|
103 | powerup.X = Level.Left + 30.0; |
---|
104 | break; |
---|
105 | default: |
---|
106 | // poweruppi tulee oikealle |
---|
107 | powerup.X = Level.Right - 30.0; |
---|
108 | break; |
---|
109 | } |
---|
110 | powerup.Y = RandomGen.NextDouble(Level.Bottom + 10.0, Level.Top - 10.0); |
---|
111 | |
---|
112 | Add(powerup); |
---|
113 | powerup.CollisionIgnorer = ignorer; |
---|
114 | AddCollisionHandler(powerup, KerattiinPowerup); |
---|
115 | } |
---|
116 | |
---|
117 | |
---|
118 | |
---|
119 | void KerattiinPowerup(PhysicsObject tormaaja, PhysicsObject kohde) |
---|
120 | { |
---|
121 | tormaaja.Destroy(); |
---|
122 | |
---|
123 | if (kohde == maila1) |
---|
124 | { |
---|
125 | if (tormaaja.Tag.ToString() == "magneetti") |
---|
126 | { |
---|
127 | if (magneettiPowerUpAktiivisena) |
---|
128 | return; |
---|
129 | |
---|
130 | KerattiinMagneettiPowerup(kohde, kohde.X + 50, kohde.Y, Key.LeftControl); |
---|
131 | return; |
---|
132 | } |
---|
133 | |
---|
134 | if (tormaaja.Tag.ToString() == "vaihdasuuntaa") |
---|
135 | { |
---|
136 | KerattiinVaihdaSuuntaaPowerup(kohde, Key.LeftShift, maila1); |
---|
137 | return; |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | if (kohde == maila2) |
---|
142 | { |
---|
143 | if (tormaaja.Tag.ToString() == "magneetti") |
---|
144 | { |
---|
145 | if (magneettiPowerUpAktiivisena) |
---|
146 | return; |
---|
147 | |
---|
148 | KerattiinMagneettiPowerup(kohde, kohde.X - 50, kohde.Y, Key.RightControl); |
---|
149 | return; |
---|
150 | } |
---|
151 | |
---|
152 | if (tormaaja.Tag.ToString() == "vaihdasuuntaa") |
---|
153 | { |
---|
154 | KerattiinVaihdaSuuntaaPowerup(kohde, Key.RightShift, maila2); |
---|
155 | return; |
---|
156 | } |
---|
157 | |
---|
158 | } |
---|
159 | } |
---|
160 | |
---|
161 | |
---|
162 | void KerattiinVaihdaSuuntaaPowerup(PhysicsObject kohde, Key k, PhysicsObject maila) |
---|
163 | { |
---|
164 | Keyboard.Enable(k); |
---|
165 | if (maila == maila1) |
---|
166 | { |
---|
167 | pelaajan1PowerUpNaytto.Image = LoadImage("powerstar"); |
---|
168 | pelaajan1PowerUpNaytto.IsVisible = true; |
---|
169 | return; |
---|
170 | } |
---|
171 | |
---|
172 | pelaajan2PowerUpNaytto.Image = LoadImage("powerstar"); |
---|
173 | pelaajan2PowerUpNaytto.IsVisible = true; |
---|
174 | } |
---|
175 | |
---|
176 | /// <summary> |
---|
177 | /// |
---|
178 | /// </summary> |
---|
179 | /// <param name="kohde">Pelaaja, jolle magneettipowerup tulee (pallo seuraa tätä pelaajaa).</param> |
---|
180 | /// <param name="x">Pallon paikka</param> |
---|
181 | /// <param name="y"></param> |
---|
182 | /// <param name="k">Enabloitava näppäin.</param> |
---|
183 | void KerattiinMagneettiPowerup(PhysicsObject kohde, double x, double y, Key k) |
---|
184 | { |
---|
185 | powerUpAjastin.Pause(); |
---|
186 | Keyboard.Enable(k); |
---|
187 | SammutaLiekki(); |
---|
188 | kummallaMagneettiPowerup = kohde; |
---|
189 | magneettiPowerUpAktiivisena = true; |
---|
190 | pallonPitaaLiikkua = false; |
---|
191 | pallo.Velocity = Vector.Zero; |
---|
192 | pallo.X = x; |
---|
193 | pallo.Y = y; |
---|
194 | pallo.IgnoresCollisionResponse = true; |
---|
195 | } |
---|
196 | |
---|
197 | private void SammutaLiekki() |
---|
198 | { |
---|
199 | liekki.FadeOut(0.5); |
---|
200 | } |
---|
201 | |
---|
202 | void LisaaAjastimet() |
---|
203 | { |
---|
204 | powerUpAjastin = new Timer(); |
---|
205 | powerUpAjastin.Interval = 2; |
---|
206 | powerUpAjastin.Trigger += LisaaPowerupKentalle; |
---|
207 | powerUpAjastin.Start(); |
---|
208 | } |
---|
209 | |
---|
210 | void LuoKentta() |
---|
211 | { |
---|
212 | pallo = new PhysicsObject(35.0, 35.0); |
---|
213 | pallo.Shape = Shapes.Circle; |
---|
214 | //pallo.Image = pallonKuva; |
---|
215 | pallo.CanRotate = true; |
---|
216 | pallo.CollisionIgnorer = ignorer; |
---|
217 | pallo.Color = Color.Black; |
---|
218 | |
---|
219 | Add(pallo); |
---|
220 | pallo.X = -200.0; |
---|
221 | pallo.Y = 0.0; |
---|
222 | |
---|
223 | vasenReuna = Level.CreateLeftBorder(); |
---|
224 | vasenReuna.Restitution = 1.0; |
---|
225 | vasenReuna.IsVisible = false; |
---|
226 | |
---|
227 | oikeaReuna = Level.CreateRightBorder(); |
---|
228 | oikeaReuna.Restitution = 1.0; |
---|
229 | oikeaReuna.IsVisible = false; |
---|
230 | |
---|
231 | ylinReuna = Level.CreateTopBorder(); |
---|
232 | ylinReuna.Restitution = 1.0; |
---|
233 | ylinReuna.IsVisible = false; |
---|
234 | |
---|
235 | alaReuna = Level.CreateBottomBorder(); |
---|
236 | alaReuna.Restitution = 1.0; |
---|
237 | alaReuna.IsVisible = false; |
---|
238 | |
---|
239 | pallo.Restitution = 1.0; |
---|
240 | Level.BackgroundColor = Color.Yellow; |
---|
241 | Camera.ZoomToLevel(); |
---|
242 | |
---|
243 | maila1 = LuoMaila(Level.Left + 30.0, 0.0); |
---|
244 | maila2 = LuoMaila(Level.Right - 30.0, 0.0); |
---|
245 | |
---|
246 | pelaajan1PowerUpNaytto = LuoPowerUpNaytto(Level.Left, Level.Bottom+70); |
---|
247 | pelaajan2PowerUpNaytto = LuoPowerUpNaytto(Level.Right, Level.Bottom+70); |
---|
248 | |
---|
249 | AddCollisionHandler(pallo, KasittelePallonTormays); |
---|
250 | |
---|
251 | } |
---|
252 | |
---|
253 | GameObject LuoPowerUpNaytto(double x, double y) |
---|
254 | { |
---|
255 | GameObject naytto = new GameObject(100, 100); |
---|
256 | naytto.Position = new Vector(x, y); |
---|
257 | naytto.IsVisible = false; |
---|
258 | Add(naytto); |
---|
259 | return naytto; |
---|
260 | } |
---|
261 | |
---|
262 | void AloitaPeli() |
---|
263 | { |
---|
264 | Vector impulssi = new Vector(500.0, 0.0); |
---|
265 | pallo.Hit(impulssi); |
---|
266 | pallonPitaaLiikkua = true; |
---|
267 | magneettiPowerUpAktiivisena = false; |
---|
268 | Keyboard.Disable(Key.LeftControl); |
---|
269 | Keyboard.Disable(Key.LeftShift); |
---|
270 | Keyboard.Disable(Key.RightControl); |
---|
271 | Keyboard.Disable(Key.RightShift); |
---|
272 | rajahdys = new ExplosionSystem(LoadImage("rajahdys"), 200); |
---|
273 | Add(rajahdys); |
---|
274 | |
---|
275 | liekki = new Flames(LoadImage("rajahdys"), 200000, Angle.Degrees(-90)); |
---|
276 | liekki.MinLifetime = 0.2; |
---|
277 | liekki.MaxLifetime = 0.5; |
---|
278 | liekki.MinScale = 1.0; |
---|
279 | liekki.MaxScale = 2.0; |
---|
280 | liekki.Position = pallo.Position; |
---|
281 | //Add(liekki); |
---|
282 | } |
---|
283 | |
---|
284 | PhysicsObject LuoMaila(double x, double y) |
---|
285 | { |
---|
286 | PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); |
---|
287 | maila.Shape = Shapes.Rectangle; |
---|
288 | maila.X = x; |
---|
289 | maila.Y = y; |
---|
290 | maila.Restitution = 1.0; |
---|
291 | Add(maila); |
---|
292 | maila.Color = Color.Black; |
---|
293 | return maila; |
---|
294 | } |
---|
295 | |
---|
296 | void AsetaOhjaimet() |
---|
297 | { |
---|
298 | Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos); |
---|
299 | Keyboard.Listen(Key.W, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); |
---|
300 | Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); |
---|
301 | Keyboard.Listen(Key.S, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); |
---|
302 | |
---|
303 | Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); |
---|
304 | Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); |
---|
305 | Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); |
---|
306 | Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); |
---|
307 | |
---|
308 | Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); |
---|
309 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); |
---|
310 | Keyboard.Listen(Key.R, ButtonState.Pressed, Resetoi, "Resettaa pallon"); |
---|
311 | Keyboard.Listen(Key.NumPad1, ButtonState.Pressed, Tausta, "Numpad 1-9 vaihta taustakuvaa", "", Color.ForestGreen); |
---|
312 | Keyboard.Listen(Key.NumPad2, ButtonState.Pressed, Tausta, null, "", Color.Aqua); |
---|
313 | Keyboard.Listen(Key.NumPad3, ButtonState.Pressed, Tausta, null, "", Color.White); |
---|
314 | Keyboard.Listen(Key.NumPad4, ButtonState.Pressed, Tausta, null, "", Color.Pink); |
---|
315 | Keyboard.Listen(Key.NumPad0, ButtonState.Pressed, Tausta, null, "", Color.Yellow); |
---|
316 | Keyboard.Listen(Key.NumPad5, ButtonState.Pressed, Tausta, null, "", Color.Purple); |
---|
317 | Keyboard.Listen(Key.NumPad8, ButtonState.Pressed, Tausta, null, "WHY SO SERIOUS 25", Color.White); |
---|
318 | Keyboard.Listen(Key.NumPad6, ButtonState.Pressed, Tausta, null, "Clouds", Color.White); |
---|
319 | Keyboard.Listen(Key.NumPad7, ButtonState.Pressed, Tausta, null, "space-art-wallpapers", Color.White); |
---|
320 | Keyboard.Listen(Key.D1, ButtonState.Pressed, Kuva, null, pallo, "trollface"); |
---|
321 | Keyboard.Listen(Key.D2, ButtonState.Pressed, Kuva, null, pallo, "planeetta"); |
---|
322 | Keyboard.Listen(Key.D3, ButtonState.Pressed, Kuva, null, pallo, "powerstar"); |
---|
323 | |
---|
324 | // Magneetti powerup |
---|
325 | Keyboard.Listen(Key.LeftControl, ButtonState.Pressed, MagneettiLaukaus, "Laukaise pallo (sieni powerup)", 2000.0); |
---|
326 | Keyboard.Listen(Key.RightControl, ButtonState.Pressed, MagneettiLaukaus, "Laukaise pallo (sieni powerup)", -2000.0); |
---|
327 | |
---|
328 | // Vaihda suuntaa powerup |
---|
329 | Keyboard.Listen(Key.LeftShift, ButtonState.Pressed, PiilotaPowerUpNaytto, null, pelaajan1PowerUpNaytto); |
---|
330 | Keyboard.Listen(Key.RightShift, ButtonState.Pressed, PiilotaPowerUpNaytto, null, pelaajan2PowerUpNaytto); |
---|
331 | Keyboard.Listen(Key.LeftShift, ButtonState.Pressed, VaihdaSuuntaaLaukaus, "Vaihda pallon suuntaa (tähti powerup)", Key.LeftShift); |
---|
332 | Keyboard.Listen(Key.RightShift, ButtonState.Pressed, VaihdaSuuntaaLaukaus, "Vaihda pallon suuntaa (tähti powerup)", Key.RightShift); |
---|
333 | } |
---|
334 | |
---|
335 | void PiilotaPowerUpNaytto(GameObject naytto) |
---|
336 | { |
---|
337 | naytto.IsVisible = false; |
---|
338 | } |
---|
339 | |
---|
340 | |
---|
341 | void Kuva(GameObject muutettavaOlio, String nimi) |
---|
342 | { |
---|
343 | muutettavaOlio.Image = LoadImage(nimi); |
---|
344 | } |
---|
345 | |
---|
346 | void Tausta(String nimi, Color vari) |
---|
347 | { |
---|
348 | if (nimi != "") |
---|
349 | { |
---|
350 | Level.Background.Image = LoadImage(nimi); |
---|
351 | Level.Background.Size = new Vector(Screen.Width, Screen.Height); |
---|
352 | return; |
---|
353 | } |
---|
354 | Level.BackgroundColor = vari; |
---|
355 | Level.Background.Image = null; |
---|
356 | } |
---|
357 | |
---|
358 | void Resetoi() |
---|
359 | { |
---|
360 | pallo.Position = new Vector(0, 0); |
---|
361 | pallo.Velocity = Vector.Zero; |
---|
362 | double x = 0; |
---|
363 | double y = 0; |
---|
364 | |
---|
365 | while (Math.Abs(x) < 350 & Math.Abs(y) < 350) |
---|
366 | { |
---|
367 | x = RandomGen.NextDouble(-500.0, 500.0); |
---|
368 | y = RandomGen.NextDouble(-500.0, 500.0); |
---|
369 | } |
---|
370 | |
---|
371 | Vector impulssi = new Vector(x, y); |
---|
372 | pallo.Hit(impulssi); |
---|
373 | |
---|
374 | } |
---|
375 | void MagneettiLaukaus(double voimaX) |
---|
376 | { |
---|
377 | pallo.Hit(new Vector(voimaX, 0)); |
---|
378 | magneettiPowerUpAktiivisena = false; |
---|
379 | liekki.FadeIn(0.5); |
---|
380 | pallonPitaaLiikkua = true; |
---|
381 | powerUpAjastin.Start(); |
---|
382 | Keyboard.Disable(Key.LeftControl); |
---|
383 | Keyboard.Disable(Key.RightControl); |
---|
384 | pallo.IgnoresCollisionResponse = false; |
---|
385 | } |
---|
386 | |
---|
387 | void VaihdaSuuntaaLaukaus(Key k) |
---|
388 | { |
---|
389 | pallo.Velocity = new Vector(-pallo.Velocity.X, pallo.Velocity.Y); |
---|
390 | Keyboard.Disable(k); |
---|
391 | } |
---|
392 | |
---|
393 | |
---|
394 | void AsetaPallonNopeus(PhysicsObject maila) |
---|
395 | { |
---|
396 | pallo.Velocity = maila.Velocity; |
---|
397 | } |
---|
398 | |
---|
399 | void AsetaNopeus(PhysicsObject maila, Vector nopeus) |
---|
400 | { |
---|
401 | maila.Velocity = nopeus; |
---|
402 | |
---|
403 | if ((nopeus.Y < 0) && (maila.Bottom < Level.Bottom)) |
---|
404 | maila.Velocity = Vector.Zero; |
---|
405 | |
---|
406 | if ((nopeus.Y > 0) && (maila.Top > Level.Top)) |
---|
407 | maila.Velocity = Vector.Zero; |
---|
408 | |
---|
409 | if (magneettiPowerUpAktiivisena) |
---|
410 | AsetaPallonNopeus(kummallaMagneettiPowerup); |
---|
411 | } |
---|
412 | |
---|
413 | void LisaaLaskurit() |
---|
414 | { |
---|
415 | pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); |
---|
416 | pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); |
---|
417 | } |
---|
418 | |
---|
419 | IntMeter LuoPisteLaskuri(double x, double y) |
---|
420 | { |
---|
421 | IntMeter laskuri = new IntMeter(0); |
---|
422 | laskuri.MaxValue = 1000000; |
---|
423 | laskuri.UpperLimit += PisteYlarajaSaavutettu; |
---|
424 | Label naytto = new Label(); |
---|
425 | naytto.BindTo(laskuri); |
---|
426 | naytto.X = x; |
---|
427 | naytto.Y = y; |
---|
428 | naytto.TextColor = Color.Black; |
---|
429 | Add(naytto); |
---|
430 | return laskuri; |
---|
431 | } |
---|
432 | |
---|
433 | void PisteYlarajaSaavutettu(int pistemaara) |
---|
434 | { |
---|
435 | pallo.Velocity = Vector.Zero; |
---|
436 | pallonPitaaLiikkua = false; |
---|
437 | |
---|
438 | if (pelaajan1Pisteet.Value == pistemaara) |
---|
439 | { |
---|
440 | Label voittoNaytto = new Label("Pelaaja 1 voitti!"); |
---|
441 | voittoNaytto.Y = 0; |
---|
442 | voittoNaytto.X = -voittoNaytto.Width / 2; |
---|
443 | Add(voittoNaytto); |
---|
444 | } |
---|
445 | |
---|
446 | if (pelaajan2Pisteet.Value == pistemaara) |
---|
447 | { |
---|
448 | Label voittoNaytto = new Label("Pelaaja 2 voitti!"); |
---|
449 | voittoNaytto.Y = 0; |
---|
450 | voittoNaytto.X = -voittoNaytto.Width / 2; |
---|
451 | Add(voittoNaytto); |
---|
452 | } |
---|
453 | } |
---|
454 | |
---|
455 | void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) |
---|
456 | { |
---|
457 | if (kohde == oikeaReuna) |
---|
458 | { |
---|
459 | pelaajan1Pisteet.Value += 1; |
---|
460 | OsumaAani.Play(); |
---|
461 | Rajahdys(pallo.Position); |
---|
462 | } |
---|
463 | else if (kohde == vasenReuna) |
---|
464 | { |
---|
465 | pelaajan2Pisteet.Value += 1; |
---|
466 | OsumaAani.Play(); |
---|
467 | Rajahdys(pallo.Position); |
---|
468 | } |
---|
469 | } |
---|
470 | |
---|
471 | void Rajahdys(Vector paikka) |
---|
472 | { |
---|
473 | rajahdys.AddEffect(paikka.X, paikka.Y, 20); |
---|
474 | } |
---|
475 | |
---|
476 | |
---|
477 | protected override void Update(Time time) |
---|
478 | { |
---|
479 | if (pallonPitaaLiikkua) |
---|
480 | { |
---|
481 | liekki.Position = pallo.Position; |
---|
482 | // Nopeuttaa pallon liikettä jos liike hidastuu |
---|
483 | if (pallo != null && Math.Abs(pallo.Velocity.X) < pallonNopeus) |
---|
484 | { |
---|
485 | pallo.Velocity = new Vector(pallo.Velocity.X * 1.1, pallo.Velocity.Y); |
---|
486 | } |
---|
487 | } |
---|
488 | base.Update(time); |
---|
489 | } |
---|
490 | } |
---|