Esempio n. 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)
        {
            // TODO: Add your drawing code here
            // test
            spriteBatch.Begin();
            switch (CurrentGameState)
            {
            case Gamestate.MainMenu:
                spriteBatch.Draw(Content.Load <Texture2D>("Menu"), new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height), Color.White);
                PlayButton.Draw(spriteBatch);
                //Options.Draw(spriteBatch);
                break;

            /*case Gamestate.Options:
             *  spriteBatch.Draw(Content.Load<Texture2D>("Menu"), new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height), Color.White);
             *  Full.Draw(spriteBatch);
             *  Back.Draw(spriteBatch);
             *  break;*/
            case Gamestate.Playing:
                GraphicsDevice.Clear(Color.Black);
                spriteBatch.DrawString(Font, m_Lives1.GetLivesStr(), new Vector2(graphics.GraphicsDevice.Viewport.Width / 4, 50), Color.White);
                spriteBatch.DrawString(Font, m_Lives2.GetLivesStr(), new Vector2(3 * (graphics.GraphicsDevice.Viewport.Width / 4), 50), Color.White);
                spriteBatch.Draw(m_BarShape1, m_Bar1.GetPos(), Color.White);
                spriteBatch.Draw(m_BarShape2, m_Bar2.GetPos(), Color.White);
                spriteBatch.Draw(m_BallShape, m_Ball.GetPos(), Color.White);
                break;

            case Gamestate.GameOver:
                GraphicsDevice.Clear(Color.Black);
                if (m_Lives1.GetLivesInt() == 0)
                {
                    string Text         = ("The winner is: Player 2, with " + m_Lives2.GetLivesStr() + " lives left.");
                    float  StringLength = Font.MeasureString(Text).X;
                    spriteBatch.DrawString(Font, Text, new Vector2(GraphicsDevice.Viewport.Width / 2 - (StringLength) / 2, GraphicsDevice.Viewport.Height / 2), Color.White);
                }
                else if (m_Lives2.GetLivesInt() == 0)
                {
                    string Text         = ("The winner is: Player 1, with " + m_Lives1.GetLivesStr() + " lives left.");
                    float  StringLength = Font.MeasureString(Text).X;
                    spriteBatch.DrawString(Font, Text, new Vector2(GraphicsDevice.Viewport.Width / 2 - (StringLength) / 2, GraphicsDevice.Viewport.Height / 2), Color.White);
                }
                Back.Draw(spriteBatch);
                break;
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }