Guest User

Untitled

a guest
Sep 25th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Xna.Framework;
  6. using Microsoft.Xna.Framework.Audio;
  7. using Microsoft.Xna.Framework.Content;
  8. using Microsoft.Xna.Framework.GamerServices;
  9. using Microsoft.Xna.Framework.Graphics;
  10. using Microsoft.Xna.Framework.Input;
  11. using Microsoft.Xna.Framework.Media;
  12.  
  13. namespace WindowsGame6
  14. {
  15. class Player
  16. {
  17. private float speed = 5.0f;
  18. private Vector2 position;
  19. public Vector2 Position
  20. {
  21. get { return position; }
  22. set { position = value; }
  23. }
  24. private Texture2D tex;
  25. public Texture2D Tex
  26. {
  27. get { return tex; }
  28. set { tex = value; }
  29. }
  30. //Makes Program More Efficient (one line comment)
  31.  
  32. /*Multiline Comment*/
  33. public Player(Vector2 position, Texture2D tex)
  34. {
  35. this.position = position;
  36. this.tex = tex;
  37.  
  38. }
  39. public void HandleInput(KeyboardState keyState, KeyboardState prevkeyState)
  40. {
  41. if (keyState.IsKeyDown(Keys.Up))
  42. {
  43. position += new Vector2(0, -1 * speed);
  44. }
  45. if (keyState.IsKeyDown(Keys.Down))
  46. {
  47. position += new Vector2(0, 1 * speed);
  48. }
  49. if (keyState.IsKeyDown(Keys.Left))
  50. {
  51. position += new Vector2(-1 * speed, 0);
  52. }
  53. if (keyState.IsKeyDown(Keys.Right))
  54. position += new Vector2(1 * speed, 0);
  55. }
  56.  
  57. }
  58. public void Draw(SpriteBatch spritebatch)
  59. {
  60. spritebatch.Draw(tex, position, Color.White);
  61. }
  62. }
  63. }
Add Comment
Please, Sign In to add comment