Exemple #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.CornflowerBlue);

            // TODO: Add your drawing code here
            spriteBatch.Begin();

            ball.Draw(spriteBatch);
            paddle.Draw(spriteBatch);

            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemple #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(new Color(20, 20, 20));

            float dist = (paddle.Collision.Position.X + paddle.Collision.Region().Width / 2) - (graphics.PreferredBackBufferWidth / 2);

            dist = Math.Min(Math.Max(dist, 0), gameWidth - graphics.PreferredBackBufferWidth);
            Matrix translation = Matrix.CreateTranslation(-dist, 0, 0);

            parallax.Draw(gameTime, spriteBatch, translation);

            spriteBatch.Begin(SpriteSortMode.BackToFront, null, SamplerState.PointClamp, null, null, null, translation);
            paddle.Draw(spriteBatch);

            foreach (Object ball in balls)
            {
                ball.Draw(spriteBatch);
            }
            foreach (Brick brick in bricks)
            {
                brick.Draw(spriteBatch);
            }
            foreach (Powerup powerup in powerups)
            {
                powerup.Draw(spriteBatch);
            }

            spriteBatch.DrawString(livesFont, "Lives: " + lives, new Vector2(dist + graphics.PreferredBackBufferWidth - 100, gameHeight - livesFont.MeasureString(" ").Y), Color.White);
            if (Winner)
            {
                Vector2 size = gameOverFont.MeasureString("YOU WIN!");
                Vector2 pos  = new Vector2(dist + graphics.PreferredBackBufferWidth / 2 - size.X / 2, gameHeight / 2 - size.Y / 2);
                spriteBatch.DrawString(gameOverFont, "YOU WIN!", pos, Color.Green, 0f, new Vector2(0), 1f, SpriteEffects.None, 0.1f);
            }
            if (GameOver)
            {
                Vector2 size = gameOverFont.MeasureString("GAME OVER");
                Vector2 pos  = new Vector2(gameWidth / 2 - size.X / 2, gameHeight / 2 - size.Y / 2);
                spriteBatch.DrawString(gameOverFont, "GAME OVER", pos, Color.Red, 0f, new Vector2(0), 1f, SpriteEffects.None, 0.1f);
            }


            spriteBatch.End();

            ParticleManager.Draw(translation);

            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.CornflowerBlue);

            // TODO: Add your drawing code here
            spriteBatch.Begin();
            spriteBatch.Draw(Scoreboard, ScoreboardRect, Color.Red);
            spriteBatch.Draw(LeftScore, LeftScoreRect, Color.Red);
            spriteBatch.Draw(RightScore, RightSCoreRect, Color.Red);
            ball.Draw(spriteBatch);
            paddle.Draw(spriteBatch);
            paddleRight.Draw(spriteBatch);

            spriteBatch.End();
            base.Draw(gameTime);
        }