- Timestamp:
- 2009-07-24 13:16:11 (14 years ago)
- Location:
- joni_j/Lil' boxhead
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
joni_j/Lil' boxhead/Peli.cs
r143 r185 29 29 PhysicsObject maali; 30 30 PhysicsObject Lehma; 31 31 Cannon ase; 32 AssaultRifle kk; 33 32 34 int elamaLaskuri; // Vielä tekemättä toteutus! 33 35 int kenttaNro; // monesko kenttä on menossa … … 63 65 aloitaUusiPeli(); 64 66 67 68 65 69 } 66 70 … … 106 110 lisaaLehma(kentta); 107 111 lisaaLippis(kentta); 108 lisaaLippis(kentta);109 112 lisaaAurinko(kentta); 110 113 lisaaCorni(kentta); … … 113 116 114 117 int vihollistenMaara = kenttaNro; 115 lisaaViholliset(kentta, vihollistenMaara);116 117 118 118 lisaaPieniTaso(kentta ,-100,-200); 119 119 lisaaPieniTaso(kentta, -200, -250); … … 125 125 lisaaPieniTaso(kentta, 1700, -100); 126 126 lisaaPieniTaso(kentta, 2110, -175.1); 127 128 129 130 Bullet luoti = new Bullet(); 131 kk = new AssaultRifle(luoti); 132 kk.Mass = 1; 133 kentta.Objects.Add(kk); 134 kk.X = 0; 135 kk.Y = 0; 136 137 138 127 139 return kentta; 140 128 141 } 129 142 … … 144 157 AddCollisionHandler(pelaaja1, osuiMaaliin); 145 158 AddCollisionHandler(pelaaja1, osuiLehmaan); 159 AddCollisionHandler(pelaaja1, osuikkhon); 146 160 kentta.Objects.Add(pelaaja1); 147 161 } … … 174 188 { 175 189 Lehma = new PhysicsObject(10000000000000000000, Shapes.CreateCircle (150)); 176 Lehma.X = RandomGen.NextDouble(1750.0, -1750.0);177 Lehma.Y = - 250.1750;190 Lehma.X = -1500; 191 Lehma.Y = -300.1750; 178 192 Lehma.Restitution = 1.0; 179 180 193 Lehma.Texture = Content.Load<Texture2D>("Lehma"); 181 194 AddCollisionHandler(Lehma, tuuppaa); 182 195 kentta.Objects.Add(Lehma); 183 196 CannonBall kuula = new CannonBall(); 197 ase = new Cannon(kuula); 198 ase.Position = Lehma.Position; 199 ase.Anchor = Lehma.Position; 200 ase.SetOwner(Lehma,kentta); 201 ase.Powered = false; 202 ase.Power = new Meter<double>(50000, 50000, 150000); 203 ase.FireRate = 0.6; 204 kentta.Objects.Add(ase); 205 ase.Equip(); 206 184 207 } 185 208 … … 200 223 //Aurinko 201 224 225 202 226 void lisaaAurinko (Level kentta) 203 227 … … 231 255 AddCollisionHandler(vihollinen, tuuppaa); 232 256 kentta.Objects.Add(vihollinen); 233 } 234 } 235 236 237 238 void lisaaViholliset(Level kentta, int kpl) 239 { 240 for (int i = 0; i < kpl; i++) 241 { 242 PlatformCharacter Vihullinen = new PlatformCharacter(100, Shapes.CreateCircle(30)); 243 Vihullinen.Brain = new RandomMoverBrain(); 244 Vihullinen.X = maali.X; 245 Vihullinen.Y = maali.Y; 246 Vihullinen.IgnoresGravity = true; 247 Vihullinen.Texture = Content.Load<Texture2D>("vihullinen"); 248 AddCollisionHandler(Vihullinen, tuuppaa); 249 kentta.Objects.Add(Vihullinen); 250 251 252 253 254 255 256 257 } 258 } 259 257 258 } 259 260 261 262 } 263 264 protected override void OnUpdate(GameTime time) 265 { 266 267 ase.Angle = Angle.Degrees(RandomGen.NextDouble(-40, 50)); 268 269 Projectile ammus = ase.Use(); 270 271 if (ammus != null) 272 { 273 Level.Objects.Add(ammus); 274 } 275 276 base.OnUpdate(time); 277 } 260 278 261 279 #endregion 262 263 264 265 280 266 281 … … 276 291 Controls.Listen(Keys.Right, ButtonPosition.Down, liikuta, "Liikkuu oikealle", pelaaja1, new Vector2D(liikeVoima, 0)); 277 292 Controls.Listen(Keys.Up, ButtonPosition.Pressed, hyppaa, "Hyppää", pelaaja1, hyppyVoima); 278 293 Controls.Listen(Keys.A, ButtonPosition.Pressed, ammu, "Ammu", pelaaja1); 279 294 lisaaGamePadNappaimet(PlayerIndex.One, pelaaja1); 295 Controls.Listen(Keys.Q, ButtonPosition.Pressed, kaanna, "käännä", pelaaja1); 280 296 } 281 297 … … 288 304 Controls.Listen(pelaajaNro, Buttons.DPadRight, ButtonPosition.Down, liikuta, "Pelaaja liikkuu oikealle", pelaaja, new Vector2D(liikeVoima, 0)); 289 305 Controls.Listen(pelaajaNro, Buttons.A, ButtonPosition.Pressed, hyppaa, "Pelaaja hyppää", pelaaja, hyppyVoima); 290 } 291 306 } 292 307 // Näppäimiin liitetyt toiminnot alkavat tästä --> 293 308 bool liikuta(ControlEvent e) … … 311 326 } 312 327 328 bool ammu(ControlEvent e) 329 { 330 PlatformCharacter hahmo = e.Parameter0 as PlatformCharacter; 331 332 Projectile ammus = kk.Use(); 333 334 if (ammus != null) 335 { 336 Level.Objects.Add(ammus); 337 } 338 339 340 return false; 341 } 342 343 bool kaanna(ControlEvent e) 344 { 345 PlatformCharacter hahmo = e.Parameter0 as PlatformCharacter; 346 347 kk.Angle += Angle.Degrees(3); 348 349 350 351 return false; 352 } 353 354 313 355 bool uusiPeli(ControlEvent e) 314 356 { … … 340 382 SiirraPelaajaAlkuun(); 341 383 } 384 } 385 386 void osuikkhon(Collision c) 387 { 388 if (c.Other == kk) 389 { 390 MessageDisplay.Add("Osuttiin konekivääriin"); 391 392 kk.Position = pelaaja1.Position; 393 kk.Anchor = pelaaja1.Position; 394 kk.SetOwner(pelaaja1, Level); 395 kk.Equip(); 396 kk.Stop(); 397 } kk.FireRate =(0.5); 342 398 } 343 399
Note: See TracChangeset
for help on using the changeset viewer.