Sprite.cs 948 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Tutorial008.Models;
  9. namespace Tutorial008.Sprites
  10. {
  11. public class Sprite
  12. {
  13. protected Texture2D _texture;
  14. public Vector2 Position;
  15. public float Speed;
  16. public Color Colour = Color.White;
  17. public Input Input;
  18. public bool IsRemoved;
  19. public Rectangle Rectangle
  20. {
  21. get
  22. {
  23. return new Rectangle((int)Position.X, (int)Position.Y, _texture.Width, _texture.Height);
  24. }
  25. }
  26. public Sprite(Texture2D texture)
  27. {
  28. _texture = texture;
  29. }
  30. public virtual void Update(GameTime gameTime, List<Sprite> sprites)
  31. {
  32. }
  33. public void Draw(SpriteBatch spriteBatch)
  34. {
  35. spriteBatch.Draw(_texture, Position, Colour);
  36. }
  37. }
  38. }