Example #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)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            // Start drawing
            spriteBatch.Begin();

            switch (gameState)
            {
            case State.Playing:
            {
                spriteBatch.Draw(mainBackground, Vector2.Zero, Color.White);

                // Draw the moving background
                bgLayer1.Draw(spriteBatch);
                bgLayer2.Draw(spriteBatch);
                //TODO: Add your drawing code here
                // Draw the Enemies
                for (int i = 0; i < enemies.Count; i++)
                {
                    enemies[i].Draw(spriteBatch);
                }
                // Draw the Projectiles
                for (int i = 0; i < projectiles.Count; i++)
                {
                    projectiles[i].Draw(spriteBatch);
                }

                // Draw the explosions
                for (int i = 0; i < explosions.Count; i++)
                {
                    explosions[i].Draw(spriteBatch);
                }
                //// Draw the score
                //spriteBatch.DrawString(font, "score: " + score, new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y), Color.White);
                // //Draw the player health
                //spriteBatch.DrawString(font, "health: " + player.Health, new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + 30), Color.White);
                //Draw the Player
                player.Draw(spriteBatch);
                player2.Draw(spriteBatch);
                break;
            }

            case State.Menu:
            {
                bgLayer1.Draw(spriteBatch);
                bgLayer2.Draw(spriteBatch);
                spriteBatch.Draw(menuItem, new Vector2(0, 0), Color.White);
                break;
            }

            case State.versus:
            {
                // Draw the moving background
                bgLayer1.Draw(spriteBatch);
                bgLayer2.Draw(spriteBatch);
                // Draw the Projectiles
                for (int i = 0; i < projectiles.Count; i++)
                {
                    projectiles[i].Draw(spriteBatch);
                }

                // Draw the explosions
                for (int i = 0; i < explosions.Count; i++)
                {
                    explosions[i].Draw(spriteBatch);
                }
                player.Draw(spriteBatch);
                player3.Draw(spriteBatch);
                break;
            }

            case State.Gameover:
            {
                spriteBatch.Draw(gameoverImage, new Vector2(0, 0), Color.White);
                //spriteBatch.DrawString("Your Final Schore was - " + new Vector2(235, 100), Color.Red);
                break;
            }
            }
            // Stop drawing
            spriteBatch.End();

            base.Draw(gameTime);
        }