- Timestamp:
- 2015-06-23 20:49:18 (6 years ago)
- Location:
- 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun.cs
r6207 r6208 18 18 * -2 - Talot taustalla. 19 19 * 20 * 20 * CollisionIgnoreGroupit 21 * 3 - Ryömivät ja liekit. //TODO: lisätä noidatkin tänne 22 * 2 - Kärry. 21 23 * 22 24 */ … … 26 28 class HillBilly : PlatformCharacter 27 29 { 28 public HillBilly(double leveys, double korkeus) 30 private IntMeter lifeCounter = new IntMeter(2, 0, 2); 31 public IntMeter Life 32 { 33 set { lifeCounter = value; } 34 get { return lifeCounter; } 35 } 36 37 public HillBilly(double leveys, double korkeus, HillbillyRun game) 29 38 : base(leveys, korkeus) 30 39 { 31 40 32 41 } 33 42 } … … 39 48 { 40 49 private List<HillBilly> players = new List<HillBilly>(); 50 private List<HillBilly> startingPlayers = new List<HillBilly>(); 51 41 52 //private List<double> playerPositionsX = new List<double>(); 42 53 //private List<double> playerPositionsY = new List<double>(); … … 79 90 } 80 91 92 #region Intro 81 93 void IntroSequence() 82 94 { … … 134 146 Add(win); 135 147 } 148 #endregion 136 149 137 150 void StartGame() … … 195 208 196 209 level.SetTileMethod(Color.Gold, CreatePlayer); 197 level.SetTileMethod(Color.Rose, CreateDummy, Color.Rose); //TODO: CreateFlame198 210 level.SetTileMethod(Color.Harlequin, CreateCart); 199 211 level.SetTileMethod(Color.White, CreateBlockObject); … … 201 213 level.SetTileMethod(Color.Gray, CreateCrawly); 202 214 level.SetTileMethod(Color.Red, CreateDummy, Color.Red); //TODO: CreateWitch 215 level.SetTileMethod(Color.Rose, CreateFlame); 216 //level.SetTileMethod(Color.Azure, CreateDummy, Color.Azure); //TODO: CreateSmoke 217 //level.SetTileMethod(Color.Orange, CreateDummy, Color.Orange); //TODO: CreateTombstone 203 218 level.Execute(TILE_SIZE, TILE_SIZE); 204 219 level.Optimize(Color.Black, Color.Brown); … … 215 230 } 216 231 232 void CreateFlame(Vector position, double width, double height) 233 { 234 PhysicsObject flame = PhysicsObject.CreateStaticObject(width, height); 235 //flame.Image = flameImage; 236 flame.Color = Color.Red; 237 flame.Position = position; 238 flame.CollisionIgnoreGroup = 3; 239 flame.Tag = "burn"; 240 Add(flame); 241 } 242 217 243 void CreateBlockObject(Vector position, double width, double height) 218 244 { … … 238 264 crawly.Animation = crawl; 239 265 crawly.Animation.Start(); 266 crawly.Tag = "burn"; 240 267 crawly.CollisionIgnoreGroup = 3; 241 268 Add(crawly); … … 304 331 void CreatePlayer(Vector position, double width, double height) 305 332 { 306 HillBilly player = new HillBilly(width, height * 2 );333 HillBilly player = new HillBilly(width, height * 2, this); 307 334 player.Shape = Shape.Rectangle; 308 335 player.Position = position + new Vector(0, height * 0.5); 309 336 player.Color = Color.White; 310 337 players.Add(player); 338 startingPlayers.Add(player); 311 339 Add(player); 340 AddCollisionHandler(player, "burn", delegate(PhysicsObject p, PhysicsObject t) 341 { 342 HillBilly billy = p as HillBilly; 343 billy.Life.Value--; 344 } 345 ); 346 347 player.Life.LowerLimit += delegate { players.Remove(player); player.Destroy(); }; 312 348 } 313 349 … … 351 387 void SetControls() 352 388 { 353 Keyboard.Listen(Key.A, ButtonState.Down, delegate { players[0].Walk(-300); }, "Player 1 moves left");354 Keyboard.Listen(Key.D, ButtonState.Down, delegate { players[0].Walk(300); }, "Player 1 moves right");355 Keyboard.Listen(Key.W, ButtonState.Down, delegate { players[0].Jump(1000); }, "Player 1 jumps");356 357 Keyboard.Listen(Key.Left, ButtonState.Down, delegate { players[1].Walk(-300); }, "Player 2 moves left");358 Keyboard.Listen(Key.Right, ButtonState.Down, delegate { players[1].Walk(300); }, "Player 2 moves right");359 Keyboard.Listen(Key.Up, ButtonState.Down, delegate { players[1].Jump(1000); }, "Player 2 jumps");389 Keyboard.Listen(Key.A, ButtonState.Down, delegate { startingPlayers[0].Walk(-300); }, "Player 1 moves left"); 390 Keyboard.Listen(Key.D, ButtonState.Down, delegate { startingPlayers[0].Walk(300); }, "Player 1 moves right"); 391 Keyboard.Listen(Key.W, ButtonState.Down, delegate { startingPlayers[0].Jump(1000); }, "Player 1 jumps"); 392 393 Keyboard.Listen(Key.Left, ButtonState.Down, delegate { startingPlayers[1].Walk(-300); }, "Player 2 moves left"); 394 Keyboard.Listen(Key.Right, ButtonState.Down, delegate { startingPlayers[1].Walk(300); }, "Player 2 moves right"); 395 Keyboard.Listen(Key.Up, ButtonState.Down, delegate { startingPlayers[1].Jump(1000); }, "Player 2 jumps"); 360 396 361 397 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Show help");
Note: See TracChangeset
for help on using the changeset viewer.