Bomb.cs 741 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Xna.Framework;
  7. using Microsoft.Xna.Framework.Graphics;
  8. namespace Tutorial007.Sprites
  9. {
  10. public class Bomb : Sprite
  11. {
  12. public Bomb(Texture2D texture)
  13. : base(texture)
  14. {
  15. Position = new Vector2(Game1.Random.Next(0, Game1.ScreenWidth - _texture.Width), -_texture.Height);
  16. Speed = Game1.Random.Next(3, 10);
  17. }
  18. public override void Update(GameTime gameTime, List<Sprite> sprites)
  19. {
  20. Position.Y += Speed;
  21. // If we hit the bottom of the window
  22. if (Rectangle.Bottom >= Game1.ScreenHeight)
  23. IsRemoved = true;
  24. }
  25. }
  26. }