Guest User

Untitled

a guest
Dec 30th, 2013
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. class Enemy : EnemySprite
  2. {
  3. const string ENEMY_ASSETNAME = "BadguyLeft";
  4. const int START_POSITION_X1 = 350;
  5. const int START_POSITION_X2 = 600;
  6. const int START_POSITION_X3 = 750;
  7. const int START_POSITION_Y = 415;
  8. const int MOVE_LEFT = -1;
  9. int WizardSpeed = 160;
  10.  
  11. enum State
  12. {
  13. Walking
  14. }
  15.  
  16. public void LoadContent(ContentManager theContentManager)
  17. {
  18.  
  19. base.LoadContent(theContentManager, ENEMY_ASSETNAME);
  20. }
  21.  
  22. public void Update(GameTime theGameTime)
  23. {
  24. //KeyboardState aCurrentKeyboardState = Keyboard.GetState();
  25.  
  26. //UpdateMovement(aCurrentKeyboardState);
  27.  
  28. //mPreviousKeyboardState = aCurrentKeyboardState;
  29. Position[0] = new Vector2(START_POSITION_X1, START_POSITION_Y);
  30. Position[1] = new Vector2(START_POSITION_X2, START_POSITION_Y);
  31. Position[2] = new Vector2(START_POSITION_X3, START_POSITION_Y);
  32.  
  33. base.Update(theGameTime, mSpeed, mDirection);
  34. }
  35.  
  36. private void UpdateMovement(KeyboardState aCurrentKeyboardState)
  37. {
  38. //int positionTracker = START_POSITION_X3;
  39.  
  40. if (mCurrentState == State.Walking)
  41. {
  42. mSpeed = Vector2.Zero;
  43. mDirection = Vector2.Zero;
  44.  
  45.  
  46. for (int i = 0; i < Position.Count(); i++)
  47. if (mCurrentState == State.Walking)
  48. {
  49. mSpeed.X = WizardSpeed;
  50. mDirection.X = MOVE_LEFT;
  51. }
  52.  
  53.  
  54.  
  55.  
  56. }
  57.  
  58. //this will move an object to the left
  59. Vector2 speed = new Vector2(-10, 0);
  60. public void Update(GameTime theGameTime)
  61. {
  62. //this will add the speed of the sprite to its position
  63. //making it move
  64. Position[0] += speed;
  65. Position[1] += speed;
  66. Position[2] += speed;
  67.  
  68. base.Update(theGameTime, mSpeed, mDirection);
  69. }
Advertisement
Add Comment
Please, Sign In to add comment