Example #1
0
        protected override void LoadContent()
        {
            // initialize sprite batching and the sprite sheet collection
            spriteBatch  = new SpriteBatch(GraphicsDevice);
            spriteSheets = SpriteSheetCollection.parseFrom(settings.spriteSheetFileName, content);
            if (spriteSheets == null)
            {
                Exit();
            }

            // initialize the game management systems
            projectileSystem = new ProjectileSystem(spriteSheets, settings, content);
            spaceShipSystem  = new SpaceShipSystem(spriteSheets, projectileSystem, settings, content);
            asteroidSystem   = new AsteroidSystem(spriteSheets, spaceShipSystem, settings);
            explosionSystem  = new ExplosionSystem(spriteSheets, content);
            scoreSystem      = new ScoreSystem(spaceShipSystem, content, settings);
            collisionSystem  = new CollisionSystem(projectileSystem, spaceShipSystem, asteroidSystem, explosionSystem, scoreSystem);

            // initialize the menu
            menu = new Menu(this, spaceShipSystem, settings, content);

            // load and start the background music (if appropriate)
            backgroundMusic         = content.Load <Song>("myg0t");
            MediaPlayer.IsRepeating = true;
            if (settings.musicEnabled)
            {
                MediaPlayer.Play(backgroundMusic);
            }
        }
Example #2
0
        public ScoreSystem(SpaceShipSystem spaceShipSystem, ContentManager content, GameSettings settings)
        {
            if(spaceShipSystem == null) { return; }

            m_players = spaceShipSystem;
            m_settings = settings;

            if(spaceShipSystem == null) { return; }

            // initialize the player scores
            m_score = new long[m_players.maxSpaceShips];
            for(int i=0;i<m_score.Length;i++) {
                m_score[i] = 0;
            }

            // initialize the score colours
            m_colourRed = new Color(255, 0, 0);
            m_colourBlue = new Color(0, 0, 255);
            m_colourGreen = new Color(0, 255, 0);
            m_colourYellow = new Color(255, 255, 0);

            if(content == null) { return; }

            // load the score font
            m_scoreFont = content.Load<SpriteFont>("ScoreFont");
        }
Example #3
0
 public CollisionSystem(ProjectileSystem projectileSystem, SpaceShipSystem spaceShipSystem, AsteroidSystem asteroidSystem, ExplosionSystem explosionSystem, ScoreSystem scoreSystem)
 {
     m_projectileSystem = projectileSystem;
     m_spaceShipSystem = spaceShipSystem;
     m_asteroidSystem = asteroidSystem;
     m_explosionSystem = explosionSystem;
     m_scoreSystem = scoreSystem;
 }
Example #4
0
 public CollisionSystem(ProjectileSystem projectileSystem, SpaceShipSystem spaceShipSystem, AsteroidSystem asteroidSystem, ExplosionSystem explosionSystem, ScoreSystem scoreSystem)
 {
     m_projectileSystem = projectileSystem;
     m_spaceShipSystem  = spaceShipSystem;
     m_asteroidSystem   = asteroidSystem;
     m_explosionSystem  = explosionSystem;
     m_scoreSystem      = scoreSystem;
 }
Example #5
0
        public AsteroidSystem(SpriteSheetCollection spriteSheets, SpaceShipSystem spaceShipSystem, GameSettings settings)
        {
            m_asteroids = new List<Asteroid>();
            if(spriteSheets != null) {
                m_asteroidSprites = spriteSheets.getSpriteSheet("Asteroids");
            }
            m_spaceShipSystem = spaceShipSystem;
            m_settings = settings;

            m_maxSmallAsteroids = 12;
            m_maxBigAsteroids = 10;
        }
Example #6
0
        public AsteroidSystem(SpriteSheetCollection spriteSheets, SpaceShipSystem spaceShipSystem, GameSettings settings)
        {
            m_asteroids = new List <Asteroid>();
            if (spriteSheets != null)
            {
                m_asteroidSprites = spriteSheets.getSpriteSheet("Asteroids");
            }
            m_spaceShipSystem = spaceShipSystem;
            m_settings        = settings;

            m_maxSmallAsteroids = 12;
            m_maxBigAsteroids   = 10;
        }
Example #7
0
        public ScoreSystem(SpaceShipSystem spaceShipSystem, ContentManager content, GameSettings settings)
        {
            if (spaceShipSystem == null)
            {
                return;
            }

            m_players  = spaceShipSystem;
            m_settings = settings;

            if (spaceShipSystem == null)
            {
                return;
            }

            // initialize the player scores
            m_score = new long[m_players.maxSpaceShips];
            for (int i = 0; i < m_score.Length; i++)
            {
                m_score[i] = 0;
            }

            // initialize the score colours
            m_colourRed    = new Color(255, 0, 0);
            m_colourBlue   = new Color(0, 0, 255);
            m_colourGreen  = new Color(0, 255, 0);
            m_colourYellow = new Color(255, 255, 0);

            if (content == null)
            {
                return;
            }

            // load the score font
            m_scoreFont = content.Load <SpriteFont>("ScoreFont");
        }
Example #8
0
        protected override void LoadContent()
        {
            // initialize sprite batching and the sprite sheet collection
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteSheets = SpriteSheetCollection.parseFrom(settings.spriteSheetFileName, content);
            if(spriteSheets == null) { Exit(); }

            // initialize the game management systems
            projectileSystem = new ProjectileSystem(spriteSheets, settings, content);
            spaceShipSystem = new SpaceShipSystem(spriteSheets, projectileSystem, settings, content);
            asteroidSystem = new AsteroidSystem(spriteSheets, spaceShipSystem, settings);
            explosionSystem = new ExplosionSystem(spriteSheets, content);
            scoreSystem = new ScoreSystem(spaceShipSystem, content, settings);
            collisionSystem = new CollisionSystem(projectileSystem, spaceShipSystem, asteroidSystem, explosionSystem, scoreSystem);

            // initialize the menu
            menu = new Menu(this, spaceShipSystem, settings, content);

            // load and start the background music (if appropriate)
            backgroundMusic = content.Load<Song>("myg0t");
            MediaPlayer.IsRepeating = true;
            if(settings.musicEnabled) {
                MediaPlayer.Play(backgroundMusic);
            }
        }
Example #9
0
        // create the game menu at a specific location
        public Menu(int x, int y, Asteroids game, SpaceShipSystem spaceShipSystem, GameSettings settings, ContentManager content)
        {
            if(content == null) { return; }

            // initialize menu colours
            m_titleColour = new Color(255, 0, 0);
            m_unselectedColour = new Color(160, 160, 160);
            m_selectedColour = new Color(255, 255, 255);
            m_arrowColour = new Color(0, 255, 0);

            // initialize menu fonts
            m_titleFont = content.Load<SpriteFont>("TitleFont");
            m_menuFont = content.Load<SpriteFont>("MenuFont");

            // initialize menu sounds
            m_scrollSound = content.Load<SoundEffect>("menu_scroll");
            m_selectSound = content.Load<SoundEffect>("menu_select");
            m_backSound = content.Load<SoundEffect>("menu_back");

            // initialize main menu
            m_mainItems = new List<MenuItem>();
            m_mainItems.Add(new MenuItem("New Game", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_mainItems.Add(new MenuItem("Resume Game", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_mainItems.Add(new MenuItem("Options", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_mainItems.Add(new MenuItem("Controls", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_mainItems.Add(new MenuItem("Help", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_mainItems.Add(new MenuItem("Quit", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));

            // initialize new game sub-menu
            m_newGameItems = new List<MenuItem>();
            m_newGameItems.Add(new MenuItem("1 Player", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_newGameItems.Add(new MenuItem("2 Player", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_newGameItems.Add(new MenuItem("3 Player", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_newGameItems.Add(new MenuItem("4 Player", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_newGameItems.Add(new MenuItem("Back", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));

            // intitialize options sub-menu
            m_optionsItems = new List<MenuItem>();
            m_optionsItems.Add(new MenuItem("Music", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_optionsItems[0].addOption("On");
            m_optionsItems[0].addOption("Off");
            m_optionsItems.Add(new MenuItem("Back", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));

            // initialize controls sub-menu
            m_controlsItems = new List<MenuItem>();
            m_controlsItems.Add(new MenuItem("Player 1 ", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_controlsItems.Add(new MenuItem("Player 2", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_controlsItems.Add(new MenuItem("Player 3", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_controlsItems.Add(new MenuItem("Player 4", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_controlsItems.Add(new MenuItem("Back", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            for(int i=0;i<4;i++) {
                m_controlsItems[i].addOption("WSAD");
                m_controlsItems[i].addOption("Arrows");
                m_controlsItems[i].addOption("C1");
                m_controlsItems[i].addOption("C2");
                m_controlsItems[i].addOption("C3");
                m_controlsItems[i].addOption("C4");
            }

            // initialize help sub-menu
            m_helpItems = new List<MenuItem>();
            m_helpItems.Add(new MenuItem("Destroy the Asteroids... or each other!", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_helpItems.Add(new MenuItem("Big Asteroids = 5 Points", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_helpItems.Add(new MenuItem("Small Asteroids = 10 Points", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_helpItems.Add(new MenuItem("Space Ships = 50 Points", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_helpItems.Add(new MenuItem("Back", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));

            // initialize menu location
            xPos = x;
            yPos = y;

            m_settings = settings;
            m_game = game;
            m_players = spaceShipSystem;

            // initialize initial menu item option selections
            m_optionsItems[0].index = (settings.musicEnabled) ? 0 : 1;
            for(int i=0;i<4;i++) {
                int itemIndex = 0;
                switch(m_settings.getInputDevice(i)) {
                    case InputDevice.WSAD:
                        itemIndex = 0;
                        break;
                    case InputDevice.Arrows:
                        itemIndex = 1;
                        break;
                    case InputDevice.Controller1:
                        itemIndex = 2;
                        break;
                    case InputDevice.Controller2:
                        itemIndex = 3;
                        break;
                    case InputDevice.Controller3:
                        itemIndex = 4;
                        break;
                    case InputDevice.Controller4:
                        itemIndex = 5;
                        break;
                }
                m_controlsItems[i].index = itemIndex;
            }
        }
Example #10
0
 // create the game menu at the default location
 public Menu(Asteroids game, SpaceShipSystem spaceShipSystem, GameSettings settings, ContentManager content)
     : this(150, 150, game, spaceShipSystem, settings, content)
 {
 }
Example #11
0
        // create the game menu at a specific location
        public Menu(int x, int y, Asteroids game, SpaceShipSystem spaceShipSystem, GameSettings settings, ContentManager content)
        {
            if (content == null)
            {
                return;
            }

            // initialize menu colours
            m_titleColour      = new Color(255, 0, 0);
            m_unselectedColour = new Color(160, 160, 160);
            m_selectedColour   = new Color(255, 255, 255);
            m_arrowColour      = new Color(0, 255, 0);

            // initialize menu fonts
            m_titleFont = content.Load <SpriteFont>("TitleFont");
            m_menuFont  = content.Load <SpriteFont>("MenuFont");

            // initialize menu sounds
            m_scrollSound = content.Load <SoundEffect>("menu_scroll");
            m_selectSound = content.Load <SoundEffect>("menu_select");
            m_backSound   = content.Load <SoundEffect>("menu_back");

            // initialize main menu
            m_mainItems = new List <MenuItem>();
            m_mainItems.Add(new MenuItem("New Game", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_mainItems.Add(new MenuItem("Resume Game", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_mainItems.Add(new MenuItem("Options", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_mainItems.Add(new MenuItem("Controls", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_mainItems.Add(new MenuItem("Help", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_mainItems.Add(new MenuItem("Quit", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));

            // initialize new game sub-menu
            m_newGameItems = new List <MenuItem>();
            m_newGameItems.Add(new MenuItem("1 Player", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_newGameItems.Add(new MenuItem("2 Player", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_newGameItems.Add(new MenuItem("3 Player", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_newGameItems.Add(new MenuItem("4 Player", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_newGameItems.Add(new MenuItem("Back", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));

            // intitialize options sub-menu
            m_optionsItems = new List <MenuItem>();
            m_optionsItems.Add(new MenuItem("Music", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_optionsItems[0].addOption("On");
            m_optionsItems[0].addOption("Off");
            m_optionsItems.Add(new MenuItem("Back", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));

            // initialize controls sub-menu
            m_controlsItems = new List <MenuItem>();
            m_controlsItems.Add(new MenuItem("Player 1 ", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_controlsItems.Add(new MenuItem("Player 2", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_controlsItems.Add(new MenuItem("Player 3", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_controlsItems.Add(new MenuItem("Player 4", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_controlsItems.Add(new MenuItem("Back", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            for (int i = 0; i < 4; i++)
            {
                m_controlsItems[i].addOption("WSAD");
                m_controlsItems[i].addOption("Arrows");
                m_controlsItems[i].addOption("C1");
                m_controlsItems[i].addOption("C2");
                m_controlsItems[i].addOption("C3");
                m_controlsItems[i].addOption("C4");
            }

            // initialize help sub-menu
            m_helpItems = new List <MenuItem>();
            m_helpItems.Add(new MenuItem("Destroy the Asteroids... or each other!", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_helpItems.Add(new MenuItem("Big Asteroids = 5 Points", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_helpItems.Add(new MenuItem("Small Asteroids = 10 Points", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_helpItems.Add(new MenuItem("Space Ships = 50 Points", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));
            m_helpItems.Add(new MenuItem("Back", m_menuFont, m_unselectedColour, m_selectedColour, m_arrowColour));

            // initialize menu location
            xPos = x;
            yPos = y;

            m_settings = settings;
            m_game     = game;
            m_players  = spaceShipSystem;

            // initialize initial menu item option selections
            m_optionsItems[0].index = (settings.musicEnabled) ? 0 : 1;
            for (int i = 0; i < 4; i++)
            {
                int itemIndex = 0;
                switch (m_settings.getInputDevice(i))
                {
                case InputDevice.WSAD:
                    itemIndex = 0;
                    break;

                case InputDevice.Arrows:
                    itemIndex = 1;
                    break;

                case InputDevice.Controller1:
                    itemIndex = 2;
                    break;

                case InputDevice.Controller2:
                    itemIndex = 3;
                    break;

                case InputDevice.Controller3:
                    itemIndex = 4;
                    break;

                case InputDevice.Controller4:
                    itemIndex = 5;
                    break;
                }
                m_controlsItems[i].index = itemIndex;
            }
        }
Example #12
0
 // create the game menu at the default location
 public Menu(Asteroids game, SpaceShipSystem spaceShipSystem, GameSettings settings, ContentManager content) :
     this(150, 150, game, spaceShipSystem, settings, content)
 {
 }