コード例 #1
0
 public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
 {
     spriteBatch.Begin();
     spriteBatch.Draw(background, Vector2.Zero, Color.White);
     cannon.Draw(gameTime, spriteBatch);
     spriteBatch.End();
 }
コード例 #2
0
    /// <summary>
    /// Draws the game world in its current state.
    /// </summary>
    /// <param name="gameTime">An object that contains information about the game time that has passed.</param>
    /// <param name="spriteBatch">The sprite batch used for drawing sprites and text.</param>
    public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
    {
        spriteBatch.Begin();

        // draw the background and score bar
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        spriteBatch.Draw(scoreBar, new Vector2(10, 10), Color.White);

        // draw all game objects
        ball.Draw(gameTime, spriteBatch);
        cannon.Draw(gameTime, spriteBatch);
        can1.Draw(gameTime, spriteBatch);
        can2.Draw(gameTime, spriteBatch);
        can3.Draw(gameTime, spriteBatch);

        // draw the score
        spriteBatch.DrawString(gameFont, "Score: " + Score, new Vector2(20, 18), Color.White);

        // draw the number of lives
        for (int i = 0; i < lives; i++)
        {
            spriteBatch.Draw(livesSprite, new Vector2(i * livesSprite.Width + 15, 60), Color.White);
        }

        // if the game is over, draw the game-over sprite
        if (lives <= 0)
        {
            spriteBatch.Draw(gameover, new Vector2(Painter.ScreenSize.X - gameover.Width, Painter.ScreenSize.Y - gameover.Height) / 2, Color.White);
        }

        spriteBatch.End();
    }
コード例 #3
0
 protected override void Draw(GameTime gameTime)
 {
     GraphicsDevice.Clear(Color.White);
     spriteBatch.Begin();
     spriteBatch.Draw(background, Vector2.Zero, Color.White);
     cannon.Draw(gameTime, spriteBatch);
     spriteBatch.End();
 }
コード例 #4
0
 /// <summary>
 /// Draws the specified sprite batch.
 /// </summary>
 /// <param name="spriteBatch">The sprite batch.</param>
 public virtual void Draw(SpriteBatch spriteBatch)
 {
     //either draw the explosion animation or the tank and cannon depending on if tank is dead
     if (Health <= 0)
     {
         //draw explosion animation
         ExplosionAnimation.Draw(spriteBatch, Color.White, SpriteEffects.None);
     }
     else
     {
         //draw tank base, cannon and health bar
         spriteBatch.Draw(BaseImg, BasePosition, null, Color.White, -MathHelper.ToRadians(BaseRotation) + MathHelper.PiOver2, new Vector2(BaseImg.Width / 2F, BaseImg.Height / 2F), IMG_SCALE_FACTOR, SpriteEffects.None, 1f);
         Cannon.Draw(spriteBatch);
         Bar.Draw(spriteBatch);
     }
 }
コード例 #5
0
ファイル: GameWorld.cs プロジェクト: nielsduif/csharpgames
    public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
    {
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        ball.Draw(gameTime, spriteBatch);
        cannon.Draw(gameTime, spriteBatch);
        can1.Draw(gameTime, spriteBatch);
        can2.Draw(gameTime, spriteBatch);
        can3.Draw(gameTime, spriteBatch);
        for (int i = 0; i < lives; i++)
        {
            spriteBatch.Draw(livesSprite, new Vector2(i * livesSprite.Width + 15, 20), Color.White);
        }

        if (IsGameOver)
        {
            spriteBatch.Draw(gameover, new Vector2(Painter.ScreenSize.X - gameover.Width, Painter.ScreenSize.Y - gameover.Height) / 2, Color.White);
        }

        spriteBatch.End();
    }