Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. public void Update(GameTime theGameTime)
  2. {
  3. Size.X = (int)Position.X;
  4. Size.Y = (int)Position.Y;
  5.  
  6. base.Update(theGameTime, mSpeed, mDirection);
  7.  
  8. if (Position.X + FrameSize > graphicsDevice.Viewport.Width)
  9. {
  10. Position.X = graphicsDevice.Viewport.Width - FrameSize;
  11. Position.Y += 50;
  12. if (mDirection.X == -1)
  13. {
  14. mDirection.X = 1;
  15. }
  16. else if (mDirection.X == 1)
  17. {
  18. mDirection.X = -1;
  19. }
  20. }
  21.  
  22. if (Position.X < 0)
  23. {
  24. Position.X = 0;
  25. Position.Y += 50;
  26. if (mDirection.X == -1)
  27. {
  28. mDirection.X = 1;
  29. }
  30. else if (mDirection.X == 1)
  31. {
  32. mDirection.X = -1;
  33. }
  34. }
  35.  
  36. if (Position.Y + Size.Height > graphicsDevice.Viewport.Height)
  37. {
  38. Position.Y = graphicsDevice.Viewport.Height - Size.Height;
  39. }
  40.  
  41. if (Position.Y < 0)
  42. {
  43. Position.Y = 0;
  44. }
  45.  
  46.  
  47. FrameTimer += theGameTime.ElapsedGameTime;
  48. if (FrameTimer >= FrameLength)
  49. {
  50. FrameTimer = TimeSpan.Zero;
  51. FrameNum = (FrameNum + 1) % FRAME_COUNT;
  52. }
  53.  
  54. if (FrameNum >= FRAME_COUNT)
  55. FrameNum = 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement