Inheritance: GameScreen
Example #1
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //load song info
            mainMenuSong = Content.Load<Song>(@"Audio\Intro"); // load menu song
            levelOneSong = Content.Load<Song>(@"Audio\LevelOne"); // load level one song
            gameOverSong = Content.Load<Song>(@"Audio\GameOver"); // load game over song
            victrySong = Content.Load<Song>(@"Audio\Victory"); // load victory song
            MediaPlayer.IsRepeating = true; // define that long is to restart once it is over

            t2dGameScreen = Content.Load<Texture2D>(@"Textures\hud"); // load hud image
            spriteFont = Content.Load<SpriteFont>(@"Fonts\Pericles"); // load font type

            startScreen = new StartScreen(this, spriteBatch, Content.Load<SpriteFont>("menufont"), Content.Load<Texture2D>("menu"));
            Components.Add(startScreen);
            startScreen.Hide();

            actionScreen = new ActionScreen(this, spriteBatch, Content.Load<Texture2D>(@"Textures\PrimaryBackground"), Content);
            Components.Add(actionScreen);
            actionScreen.Hide();

            instructionsScreen = new InstructionsScreen(this, spriteBatch, Content.Load<SpriteFont>("menufont"), Content.Load<Texture2D>("InstructionBook"));
            Components.Add(instructionsScreen);
            instructionsScreen.Hide();

            creditScreen = new CreditScreen(this, spriteBatch, Content.Load<SpriteFont>("menufont"), Content.Load<Texture2D>("menu"));
            Components.Add(creditScreen);
            creditScreen.Hide();

            quitScreen = new PopUpScreen(
                this,
                spriteBatch,
                Content.Load<SpriteFont>("menufont"),
                Content.Load<Texture2D>("alienmetal"));
            Components.Add(quitScreen);
            quitScreen.Hide();

            gOverScreen = new GameOverScreen(
                this,
                spriteBatch,
                Content.Load<SpriteFont>("menufont"),
                Content.Load<Texture2D>(@"Textures\gameover"));
            Components.Add(gOverScreen);
            gOverScreen.Hide();

            victoryScreen = new VictoryScreen(this,spriteBatch,
                 Content.Load<SpriteFont>("menufont"),
                 Content.Load<Texture2D>(@"Textures\victory"));
            Components.Add(victoryScreen);
            victoryScreen.Hide();

            actionScreen.desiredHeight = 600; // set the height of the action screen
            actionScreen.desiredWidth = 800; // set the width of the action screen

            // set the display resolution
            graphics.PreferredBackBufferHeight = actionScreen.desiredHeight;
            graphics.PreferredBackBufferWidth = actionScreen.desiredWidth;
            graphics.ApplyChanges();
            actionScreen.lowerLimitShipPosition = actionScreen.desiredHeight - 53; // sets lowest position of the ship to be 53 pixels less than height of game because of the HUB
            actionScreen.upperLimitShipPosition = 36; // sets highest position that the ship can move 36 because of the HUB
            actionScreen.leftLimitShipPosition = 0; // does not allow ship to move outside of the screen in the left side
            actionScreen.rightLimitShipPosition = actionScreen.desiredWidth - 72; // 72 is the size of the ship sprite.
            actionScreen.pixelsToMoveInYPosition = 3; // it is how many pixels - how fast - i want the ship to move in the y position
            actionScreen.pixelsToMoveInXPosition = 3; // it is how many pixels - how fast - i want the ship to move in the x position
            actionScreen.pixelsToMoveBackgroundPosition = 6; // defines the speed that the background should be constantly moving
            activeScreen = startScreen; // set the active screen to the start screen - this is the first screen that will be shown for the user
            activeScreen.Show(); // show the first screen
        }
Example #2
0
        public void Initialize()
        {
            Game game = MockRepository.GenerateStub<Game>();
            testGame = MockRepository.GenerateStub<Starfighter>(game);

            action = new ActionScreen(game,testGame.spriteBatch);
        }