Advertisement
Guest User

Untitled

a guest
Aug 5th, 2014
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. private void timer1_Tick(object sender, EventArgs e)
  2. {
  3. RegisterBlocks();
  4. }
  5. void playerSkin()
  6. {
  7. if (!jump && !right && !left)
  8. {
  9. player.Image = Image.FromFile("stand.png");
  10. }
  11. }
  12. void checkColision(PictureBox block)
  13. {
  14. //Colision
  15. //Right
  16. if (player.Left + player.Width >= block.Left && block.Left + player.Width > player.Left && player.Top < block.Top && player.Bottom > block.Bottom)
  17. {
  18. right = false;
  19. player.Left = block.Left - player.Width;
  20. }
  21. //Left
  22. if (block.Right + player.Width >= player.Right && block.Right + player.Width <= player.Right + block.Width && block.Bottom + block.Height >= player.Bottom + 5 && block.Top <= player.Top)
  23. {
  24. left = false;
  25. player.Left = block.Right;
  26. }
  27. //Top
  28. if (player.Left + player.Width > block.Left && player.Left < block.Left + block.Width && player.Top + player.Height >= block.Top && player.Top < block.Top)
  29. {
  30. player.Top = block.Top - player.Height;
  31. force = 0;
  32. onObject = true;
  33. jump = false;
  34. }
  35. else
  36. {
  37. onObject = false;
  38. }
  39. //Bottom
  40. if (player.Left + player.Width > block.Left && player.Left < block.Left + block.Width && player.Bottom > block.Bottom && player.Bottom <= block.Bottom + player.Height + 3)
  41. {
  42. force = -1;
  43. }
  44. }
  45. void RegisterBlocks()
  46. {
  47. checkColision(b3);
  48. checkColision(b1);
  49. checkColision(b2);
  50. checkColision(block); // This one is the only block that is not 'jumpy'
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement