Time for action – building the AsteroidManager class

  1. Add a new class called "AsteroidManager" to the Asteroid Belt Assault project.
  2. Add the following using directives to the top of the AsteroidManager class:
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;
  3. Add the following declarations to the AsteroidManager class:
    private int screenWidth = 800;
    private int screenHeight = 600;
    private int screenPadding = 10;
    
    private Rectangle initialFrame;
    private int asteroidFrames;
    private Texture2D texture;
    
    public List<Sprite> Asteroids = new List<Sprite>();
    private int minSpeed = 60;
    private int maxSpeed = 120;
    
    private Random rand = new Random();
  4. Add a helper method that will be used in the AsteroidManager constructor:
    public void AddAsteroid() ...

Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.