Пример #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            // TODO: Add your drawing code here

            spriteBatch.Begin();

            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Draw(titleScreen,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);
            }

            if ((gameState == GameStates.Playing) ||
                (gameState == GameStates.PlayerDead) ||
                (gameState == GameStates.GameOver))
            {
                starField.Draw(spriteBatch);
                asteroidManager.Draw(spriteBatch);
                playerManager.Draw(spriteBatch);
                enemyManager.Draw(spriteBatch);
            }

            if ((gameState == GameStates.GameOver))
            {
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
Пример #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Draw(titleScreen,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);
            }

            if ((gameState == GameStates.Playing) ||
                (gameState == GameStates.PlayerDead) ||
                (gameState == GameStates.GameOver))
            {
                starField.Draw(spriteBatch);
                asteroidManager.Draw(spriteBatch);
                playerManager.Draw(spriteBatch);
                enemyManager.Draw(spriteBatch);
                explosionManager.Draw(spriteBatch);

                spriteBatch.DrawString(
                    pericles14,
                    "Score: " + playerManager.PlayerScore.ToString(),
                    scoreLocation,
                    Color.White);

                if (playerManager.LivesRemaining >= 0)
                {
                    spriteBatch.DrawString(
                        pericles14,
                        "Ships Remaining: " +
                        playerManager.LivesRemaining.ToString(),
                        livesLocation,
                        Color.White);
                }
            }

            if ((gameState == GameStates.GameOver))
            {
                spriteBatch.DrawString(
                    pericles14,
                    "G A M E  O V E R !",
                    new Vector2(
                        this.Window.ClientBounds.Width / 2 -
                        pericles14.MeasureString("G A M E  O V E R !").X / 2,
                        50),
                    Color.White);
            }


            spriteBatch.End();

            EffectManager.Draw();

            base.Draw(gameTime);
        }
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Draw(titleScreen,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);
            }

            if (gameState == GameStates.DifficultySelect)
            {
                spriteBatch.Draw(levelScreen,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);
            }

            if (gameState == GameStates.ccViewer)
            {
                spriteBatch.Draw(ccViewer,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);
            }

            if (gameState == GameStates.CreditsScreen)
            {
                spriteBatch.Draw(credits,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);
            }

            if ((gameState == GameStates.Playing) ||
                (gameState == GameStates.PlayerDead) ||
                (gameState == GameStates.GameOver))
            {
                starField.Draw(spriteBatch);
                planetManager.Draw(spriteBatch);
                asteroidManager.Draw(spriteBatch);
                playerManager.Draw(spriteBatch);
                enemyManager.Draw(spriteBatch);
                explosionManager.Draw(spriteBatch);


                if (difficultyLevel != 9)
                {
                    spriteBatch.DrawString(
                        pericles14,
                        "Score: " + playerManager.PlayerScore.ToString(),
                        scoreLocation,
                        Color.White);
                }
                if (playerManager.LivesRemaining >= 0)
                {
                    spriteBatch.DrawString(
                        pericles14,
                        "Ships Remaining: " +
                        (playerManager.LivesRemaining + 1).ToString(),
                        livesLocation,
                        Color.White);
                }

                if (difficultyLevel == 9)
                {
                    //Added a timer
                    playerTimePlayed +=
                        (float)gameTime.ElapsedGameTime.TotalSeconds;
                    spriteBatch.DrawString(
                        pericles14,
                        "Score: " +
                        ((int)playerTimePlayed * 100).ToString(),
                        timerLocation,
                        Color.White);
                }
            }

            if ((gameState == GameStates.GameOver))
            {
                spriteBatch.DrawString(
                    pericles14,
                    "G A M E  O V E R ! \nY O U  A R E  B A D!",
                    new Vector2(
                        this.Window.ClientBounds.Width / 2 -
                        pericles14.MeasureString("G A M E  O V E R !").X / 2,
                        50),
                    Color.White);
            }


            spriteBatch.End();
            EffectManager.Draw();

            base.Draw(gameTime);
        }
Пример #4
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Draw(titleScreen,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);
            }

            if ((gameState == GameStates.Playing) ||
                (gameState == GameStates.PlayerDead) ||
                (gameState == GameStates.GameOver) ||
                (gameState == GameStates.LevelUp))
            {
                starField.Draw(spriteBatch);
                planetManager.Draw(spriteBatch);
                asteroidManager.Draw(spriteBatch);

                playerManager.Draw(spriteBatch);
                enemyManager.Draw(spriteBatch);
                explosionManager.Draw(spriteBatch);


                spriteBatch.DrawString(
                    pericles14,
                    "Level: " + playerManager.CurrentLevel.ToString(),
                    levelLocation,
                    Color.White);

                spriteBatch.DrawString(
                    pericles14,
                    "Score: " + playerManager.PlayerScore.ToString(),
                    scoreLocation,
                    Color.White);

                spriteBatch.DrawString(
                    pericles14,
                    "Health: " + playerManager.healthRemaining.ToString(),
                    healthLocation,
                    Color.White);
                if (playerManager.healthRemaining <= 0)
                {
                    playerManager.Destroyed = true;
                }

                if (playerManager.LivesRemaining >= 0)
                {
                    spriteBatch.DrawString(
                        pericles14,
                        "Ships Remaining: " +
                        playerManager.LivesRemaining.ToString(),
                        livesLocation,
                        Color.White);
                }
            }

            if (playerManager.PlayerScore == 20000)
            {
                playerManager.LivesRemaining = +3;
            }

            if ((gameState == GameStates.PlayerDead))
            {
                spriteBatch.DrawString(
                    pericles14,
                    "Y O U   D I E D",
                    new Vector2(
                        this.Window.ClientBounds.Width / 2 -
                        pericles14.MeasureString("Y O U   D I E D").X / 2,
                        50),
                    Color.White);
            }
            if ((gameState == GameStates.GameOver))
            {
                spriteBatch.DrawString(
                    pericles14,
                    "G I T   G U D",
                    new Vector2(
                        this.Window.ClientBounds.Width / 2 -
                        pericles14.MeasureString("G I T   G U D").X / 2,
                        50),
                    Color.White);
            }
            if ((gameState == GameStates.LevelUp))
            {
                spriteBatch.DrawString(
                    pericles14,
                    "L E V E L   U P",
                    new Vector2(
                        this.Window.ClientBounds.Width / 2 -
                        pericles14.MeasureString("L E V E L   U P").X / 2,
                        50),
                    Color.White);
            }
            if ((gameState == GameStates.Win))
            {
                spriteBatch.DrawString(
                    pericles14,
                    "Y O U   W I N",
                    new Vector2(
                        this.Window.ClientBounds.Width / 2 -
                        pericles14.MeasureString("L E V E L   U P").X / 2,
                        50),
                    Color.White);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
Пример #5
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Draw(titleScreen,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);
            }

            if ((gameState == GameStates.Playing) ||
                (gameState == GameStates.PlayerDead) ||
                (gameState == GameStates.GameOver) ||
                gameState == GameStates.BossBattle)
            {
                for (int i = 0; i < starFields.Count; i++)
                {
                    starFields[i].Draw(spriteBatch);
                }
                planetManager.Draw(spriteBatch);

                if (gameState != GameStates.BossBattle)
                {
                    asteroidManager.Draw(spriteBatch);
                    enemyManager.Draw(spriteBatch);
                }
                else
                {
                    bossManager.Draw(spriteBatch);
                }

                playerManager.Draw(spriteBatch);

                explosionManager.Draw(spriteBatch);

                spriteBatch.DrawString(
                    pericles14,
                    "Score: " + playerManager.PlayerScore.ToString(),
                    scoreLocation,
                    Color.White);

                spriteBatch.DrawString(
                    pericles14,
                    "Health: " + playerManager.HealthRemaining.ToString(),
                    healthLocation,
                    Color.White);

                if (playerManager.LivesRemaining >= 0)
                {
                    spriteBatch.DrawString(
                        pericles14,
                        "Ships Remaining: " +
                        playerManager.LivesRemaining.ToString(),
                        livesLocation,
                        Color.White);
                }
                if (playerManager.HealthRemaining <= 0)
                {
                    playerManager.Destroyed = true;
                }
            }
            if ((playerManager.Destroyed == true))
            {
                spriteBatch.DrawString(
                    pericles14,
                    "Y O U  D I E D !",
                    new Vector2(
                        this.Window.ClientBounds.Width / 2 -
                        pericles14.MeasureString("Y O U  D I E D !").X / 2,
                        50),
                    Color.White);
            }
            if ((gameState == GameStates.GameOver))
            {
                spriteBatch.DrawString(
                    pericles14,
                    "G A M E  O V E R !",
                    new Vector2(
                        this.Window.ClientBounds.Width / 2 -
                        pericles14.MeasureString("G A M E  O V E R !").X / 2,
                        50),
                    Color.White);
            }
            if (gameState == GameStates.YouWin)
            {
                spriteBatch.Draw(Winner,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);
            }


            spriteBatch.End();

            base.Draw(gameTime);
        }
Пример #6
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Draw(titleScreen,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);
            }

            if ((gameState == GameStates.Playing) ||
                (gameState == GameStates.PlayerDead) ||
                (gameState == GameStates.GameOver))
            {
                foreach (StarField sf in starField)
                {
                    sf.Draw(spriteBatch);
                }
                spriteBatch.Draw(planetsmash, new Rectangle(-50, this.Window.ClientBounds.Height - planetsmash.Height + 50, planetsmash.Width, planetsmash.Height), Color.White);


                asteroidManager.Draw(spriteBatch);
                playerManager.Draw(spriteBatch);
                enemyManager.Draw(spriteBatch);
                explosionManager.Draw(spriteBatch);

                spriteBatch.DrawString(
                    pericles14,
                    "Score: " + playerManager.PlayerScore.ToString(),
                    scoreLocation,
                    Color.White);

                if (playerManager.LivesRemaining >= 0)
                {
                    spriteBatch.DrawString(
                        pericles14,
                        "Ships Remaining: " +
                        playerManager.LivesRemaining.ToString(),
                        livesLocation,
                        Color.White);
                }

                MouseState ms    = Mouse.GetState();
                Vector2    click = new Vector2(ms.X, ms.Y);

                spriteBatch.Draw(spriteSheet, new Rectangle(ms.X - 19, ms.Y - 19, 38, 38), new Rectangle(0, 356, 38, 38), Color.White);
            }

            if ((gameState == GameStates.GameOver))
            {
                spriteBatch.DrawString(
                    pericles14,
                    "G A M E  O V E R !",
                    new Vector2(
                        this.Window.ClientBounds.Width / 2 -
                        pericles14.MeasureString("G A M E  O V E R !").X / 2,
                        50),
                    Color.White);
            }


            spriteBatch.End();

            base.Draw(gameTime);
        }