- Timestamp:
- 2015-06-23 23:27:22 (7 years ago)
- Location:
- 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun
- Files:
-
- 17 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun.cs
r6217 r6218 29 29 { 30 30 private IntMeter lifeCounter = new IntMeter(2, 0, 2); 31 public IntMeter Life 31 public IntMeter Life 32 32 { 33 33 set { lifeCounter = value; } 34 get { return lifeCounter; } 34 get { return lifeCounter; } 35 35 } 36 36 … … 40 40 : base(leveys, korkeus) 41 41 { 42 42 43 43 } 44 44 } … … 55 55 //private List<double> playerPositionsY = new List<double>(); 56 56 57 private const double PLAYER_SPEED = 180; 57 58 private const double TILE_SIZE = 70; 58 59 … … 67 68 private Image[] groundTopImages = LoadImages("ground_top"); 68 69 private Image[] foregroundDecorations = LoadImages("viljaa"); 69 private Image[] blockImages = LoadImages("box ");70 private Image[] blockImages = LoadImages("box2"); 70 71 71 72 private Image[] houseImages = LoadImages("house", "houseburned"); … … 73 74 private Image cartImage = LoadImage("cart"); 74 75 private Image milkImage = LoadImage("tonkkaitem"); 75 76 76 77 private Image cartWheelImage = LoadImage("cartwheel"); 77 78 … … 90 91 private Animation normalWalk; 91 92 private Animation playerIdle; 92 #endregion 93 private Animation playerJump; 94 private Animation playerFall; 95 #endregion 93 96 94 97 private double leftCamLimit; … … 97 100 98 101 private int levelNumber = 0; 99 102 100 103 public override void Begin() 101 104 { … … 111 114 112 115 Keyboard.Listen(Key.Escape, ButtonState.Pressed, SkipIntro, "Skip"); 113 116 114 117 ShowMadeWithJypeli(); 115 118 … … 118 121 ShowBackgroundStory(); 119 122 }); 120 123 121 124 122 125 … … 126 129 { 127 130 Image madewithImage = LoadImage("madewithjypeli"); 128 131 129 132 double w = Window.Width / 4; 130 133 double h = w * (madewithImage.Height / (double)madewithImage.Width); // take aspect ratio from the picture 131 134 132 135 GameObject madewithjypeliObject = new GameObject(w, h); 133 136 madewithjypeliObject.Image = madewithImage; … … 143 146 //}; 144 147 //fadeTimer.Start(5); 145 148 146 149 Timer.SingleShot(1.2, delegate 147 150 { … … 266 269 normalWalk = LoadAnimation("pwalk"); 267 270 playerIdle = LoadAnimation("idle"); 271 playerJump = LoadAnimation("jump"); 272 playerFall = LoadAnimation("fall"); 268 273 } 269 274 … … 301 306 level.SetTileMethod(Color.Gold, CreatePlayer); 302 307 level.SetTileMethod(Color.Harlequin, CreateCart); 303 level.SetTileMethod(Color.White, CreateBlockObject); 304 level.SetTileMethod(Color.DarkGray, CreateMilk); 308 level.SetTileMethod(Color.White, CreateBlockObject); 309 level.SetTileMethod(Color.DarkGray, CreateMilk); 305 310 level.SetTileMethod(Color.Gray, CreateCrawly); 306 311 level.SetTileMethod(Color.Red, CreateDummy, Color.Red); //TODO: CreateWitch 307 level.SetTileMethod(Color.Rose, CreateFlame); 312 level.SetTileMethod(Color.Rose, CreateFlame); 308 313 //level.SetTileMethod(Color.Azure, CreateDummy, Color.Azure); //TODO: CreateSmoke 309 314 //level.SetTileMethod(Color.Orange, CreateDummy, Color.Orange); //TODO: CreateTombstone 310 315 level.Optimize(Color.Black, Color.Brown); 311 316 level.Execute(TILE_SIZE, TILE_SIZE); 312 317 313 318 314 319 //TileMap level = TileMap.FromLevelAsset("level" + levelNumber); … … 350 355 void CreateBlockObject(Vector position, double width, double height) 351 356 { 357 // Säädin vähän tätä jotta laatikko näkyy hyvin. Pitää ehkä tehdä laatikolle ihan oma metodi. 358 352 359 PhysicsObject block = PhysicsObject.CreateStaticObject(width, height); 353 block.Image = blockImages[levelNumber]; 360 block.IsVisible = false; 361 //block.Image = blockImages[levelNumber]; 354 362 block.Position = position; 355 Add(block); 363 block.Y -= height / 2.0; 364 Add(block, 1); 365 366 GameObject visibleBlock = new GameObject(width, height * 1.5); 367 visibleBlock.Position = position; 368 visibleBlock.Image = blockImages[levelNumber]; 369 visibleBlock.Y -= height / 2.0; 370 Add(visibleBlock, -1); 356 371 } 357 372 358 373 void CreateMilk(Vector position, double width, double height) 359 374 { 360 GameObject milk = new GameObject(milkImage.Width, milkImage.Height); 375 double size = 30; 376 double ratio = milkImage.Height / milkImage.Width; 377 PhysicsObject milk = new PhysicsObject(size, size * ratio); 361 378 milk.Image = milkImage; 362 379 milk.Position = position; … … 405 422 Add(house, -2); 406 423 407 PhysicsObject platform = PhysicsObject.CreateStaticObject(house.Width * 0.25, 1);424 PhysicsObject platform = PhysicsObject.CreateStaticObject(house.Width * 0.25, 1); 408 425 platform.IsVisible = false; 409 426 platform.Position = new Vector(house.X + platform.Width * 0.5, house.Top); … … 445 462 player.AnimWalk = new Animation(normalWalk); 446 463 player.AnimIdle = new Animation(playerIdle); 464 player.AnimJump = new Animation(playerJump); 465 player.AnimFall = new Animation(playerFall); 466 player.AnimFall.StopOnLastFrame = true; 447 467 players.Add(player); 448 468 startingPlayers.Add(player); 449 469 Add(player); 450 AddCollisionHandler(player, "burn", delegate(PhysicsObject p, PhysicsObject t) 470 AddCollisionHandler(player, "burn", delegate(PhysicsObject p, PhysicsObject t) 451 471 { 452 472 HillBilly billy = p as HillBilly; … … 455 475 }); 456 476 457 player.Life.LowerLimit += delegate 458 { 477 player.Life.LowerLimit += delegate 478 { 459 479 if (players.Count < 2) 460 480 { … … 463 483 players.Remove(player); player.Destroy(); 464 484 }; 485 486 AddCollisionHandler(player, "milk", CollectMilk); 465 487 } 466 488 … … 494 516 } 495 517 496 void CreateGround(Vector position, double width, double height) 518 void CreateGround(Vector position, double width, double height) 497 519 { 498 520 PhysicsObject ground = PhysicsObject.CreateStaticObject(width, height); … … 506 528 void SetControls() 507 529 { 508 double speed = 180; // TODO: Siirrä tämä johonkin. 509 Keyboard.Listen(Key.A, ButtonState.Down, delegate { startingPlayers[0].Walk(-speed); }, "Player 1 moves left"); 510 Keyboard.Listen(Key.D, ButtonState.Down, delegate { startingPlayers[0].Walk(speed); }, "Player 1 moves right"); 530 Keyboard.Listen(Key.A, ButtonState.Down, delegate { startingPlayers[0].Walk(-PLAYER_SPEED); }, "Player 1 moves left"); 531 Keyboard.Listen(Key.D, ButtonState.Down, delegate { startingPlayers[0].Walk(PLAYER_SPEED); }, "Player 1 moves right"); 511 532 Keyboard.Listen(Key.W, ButtonState.Down, delegate { startingPlayers[0].Jump(1000); }, "Player 1 jumps"); 512 533 513 Keyboard.Listen(Key.Left, ButtonState.Down, delegate { startingPlayers[1].Walk(- speed); }, "Player 2 moves left");514 Keyboard.Listen(Key.Right, ButtonState.Down, delegate { startingPlayers[1].Walk( speed); }, "Player 2 moves right");534 Keyboard.Listen(Key.Left, ButtonState.Down, delegate { startingPlayers[1].Walk(-PLAYER_SPEED); }, "Player 2 moves left"); 535 Keyboard.Listen(Key.Right, ButtonState.Down, delegate { startingPlayers[1].Walk(PLAYER_SPEED); }, "Player 2 moves right"); 515 536 Keyboard.Listen(Key.Up, ButtonState.Down, delegate { startingPlayers[1].Jump(1000); }, "Player 2 jumps"); 516 537 … … 523 544 //TODO: Sumthin' flashy for our fallen friends. 524 545 Exit(); 546 } 547 548 void CollectMilk(PhysicsObject player, PhysicsObject milk) 549 { 550 HillBilly billy = player as HillBilly; 551 if (billy == null) 552 return; 553 554 milk.Destroy(); 555 billy.AnimWalk = new Animation(milkWalk); 556 billy.AnimIdle = new Animation(milkWalk.CurrentFrame); 525 557 } 526 558 -
2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRunContent/HillbillyRunContent.contentproj
r6217 r6218 202 202 </Compile> 203 203 </ItemGroup> 204 <ItemGroup> 205 <Compile Include="fall.anim"> 206 <Name>fall</Name> 207 <Importer>AnimationImporter</Importer> 208 <Processor>AnimationContentProcessor</Processor> 209 </Compile> 210 <Compile Include="jump.anim"> 211 <Name>jump</Name> 212 <Importer>AnimationImporter</Importer> 213 <Processor>AnimationContentProcessor</Processor> 214 </Compile> 215 </ItemGroup> 204 216 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 205 217 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.