Changeset 5562 for 2014/30/JouniP/Syonti/Syonti/Syonti/Syonti.cs
- Timestamp:
- 2014-07-23 09:29:43 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/30/JouniP/Syonti/Syonti/Syonti/Syonti.cs
r5559 r5562 16 16 Vector nopeusAlas = new Vector( 0, -200); 17 17 18 // oletus, min, max 19 IntMeter pelaajanHealth = new IntMeter(10, 0, 10); 20 18 21 public override void Begin() 19 22 { 23 SetWindowSize(800, 600); 24 Level.Size = new Vector(800, 600); 25 20 26 LuoPelaaja(); 21 27 22 28 // Tehdään muut pallot kenttään: 23 LuoUseitaPalloja(50 );29 LuoUseitaPalloja(50, Color.Beige, "kerattava"); 24 30 31 LuoUseitaPalloja(10, Color.Black, "pahis"); 32 33 34 Label pisteNaytto = new Label(); 35 pisteNaytto.X = Screen.Left + 100; 36 pisteNaytto.Y = Screen.Top - 100; 37 pisteNaytto.TextColor = Color.Black; 38 pisteNaytto.Color = Color.White; 39 40 pisteNaytto.BindTo(pelaajanHealth); 41 pisteNaytto.IntFormatString = "Elämää: {0:D1}"; 42 Add(pisteNaytto); 43 44 45 Level.CreateBorders(); 25 46 LisaaNappaimet(); 26 47 } … … 51 72 void LuoPelaaja() 52 73 { 53 pelaaja = LuoPallo(0.0, 0.0, 20.0, Color.Red);74 pelaaja = LuoPallo(0.0, 0.0, 30.0, Color.Red); 54 75 Add(pelaaja, 1); 76 pelaajanHealth.LowerLimit += PelaajaHaviaa; 77 78 AddCollisionHandler(pelaaja, "kerattava", PelaajaOsuuKerattavaan); 79 AddCollisionHandler(pelaaja, "pahis", PelaajaOsuuPahikseen); 55 80 } 56 81 57 void LuoUseitaPalloja(int maara) 82 void PelaajaHaviaa() 83 { 84 Explosion rajahdys = new Explosion(200); 85 rajahdys.Position = pelaaja.Position; 86 Add(rajahdys); 87 88 pelaaja.Destroy(); 89 MessageDisplay.Add("Hävisit!"); 90 } 91 92 void PelaajaOsuuKerattavaan(PhysicsObject tormaaja, PhysicsObject kohde) 93 { 94 kohde.Destroy(); 95 tormaaja.Size = tormaaja.Size + new Vector(10, 10); 96 } 97 98 void PelaajaOsuuPahikseen(PhysicsObject tormaaja, PhysicsObject kohde) 99 { 100 if (tormaaja.Width > 35) 101 { 102 tormaaja.Size = tormaaja.Size - new Vector(30, 30); 103 } 104 pelaajanHealth.Value -= 1; 105 106 } 107 108 void LuoUseitaPalloja(int maara, Color vari, string tagiteksti) 58 109 { 59 110 int i = 0; … … 62 113 double x = RandomGen.NextDouble(Level.Left, Level.Right); 63 114 double y = RandomGen.NextDouble(Level.Bottom, Level.Top); 64 PhysicsObject p = LuoPallo(x, y, 40.0, Color.Beige); 115 PhysicsObject p = LuoPallo(x, y, 20.0, vari); 116 p.Tag = tagiteksti; 65 117 Add(p); 66 118 i++; … … 73 125 pallura.Position = new Vector(x, y); 74 126 pallura.Color = vari; 127 pallura.Tag = "pelaaja"; 75 128 return pallura; 76 129 }
Note: See TracChangeset
for help on using the changeset viewer.