コード例 #1
0
 private void DrawBullets()
 {
     for (int i = 0; i < brickBreaker.Bullets.Count; i++)
     {
         spriteBatch.Draw(CoreGlobals.BlankTexture, brickBreaker.Bullets[i].rectangle, brickBreaker.Bullets[i].color);
     }
     if (brickBreaker.bulletsRemain > 0)
     {
         spriteBatch.Draw(CoreGlobals.BlankTexture, brickBreaker.iconRect, Color.Red);
         spriteBatch.DrawString(font, brickBreaker.bulletsRemain.ToString(), new Vector2(brickBreaker.ScreenSize.X - 20, brickBreaker.ScreenSize.Y - 15), Color.White, 0f, Vector2.Zero, 0.3f, SpriteEffects.None, 0f);
     }
 }
コード例 #2
0
        void DrawPlay()
        {
            entitiesAlive = 0;

            foreach (var entity in game.Entities)
            {
                switch (entity.Type)
                {
                case EntityType.PlayerBullet:
                    DrawPlayerBullet(entity.Position);
                    ++entitiesAlive;
                    break;

                case EntityType.None:
                    break;

                default:
                    DrawAnimatedSprite(entity.Type, entity.Position);
                    ++entitiesAlive;
                    break;
                }
            }

            spriteBatch.DrawBox(new Rectangle(0, 20, game.ScreenSize.X, game.ScreenSize.Y - 20), game.BorderSize, Color.Purple, 0);
            spriteBatch.DrawString(font, entitiesAlive.ToString(), Vector2.Zero, entitiesAlive < game.Entities.Length ? Color.White : Color.Red, 0, Vector2.Zero, 0.3f, SpriteEffects.None, 0);
        }
コード例 #3
0
 void DrawHud()
 {
     spriteBatch.DrawString(font, game.ScoreText1, new Vector2(4f, 0f), Color.White, 0f, Vector2.Zero, 0.4f, SpriteEffects.None, 0f);
     spriteBatch.DrawString(font, game.ScoreText2, new Vector2(220, 0f), Color.White, 0f, Vector2.Zero, 0.4f, SpriteEffects.None, 0f);
 }
コード例 #4
0
        void DrawHud()
        {
            var srcRect = new Rectangle(84, 39, 10, 4);
            var rect    = new Rectangle(2, 2, 10, 4);

            for (int i = 0; i < Math.Min(5, game.PlayerLives); ++i)
            {
                spriteBatch.Draw(SpriteSheet, rect, srcRect, Color.White);
                rect.X += srcRect.Width + 2;
            }

            spriteBatch.DrawString(font, game.ScoreText, new Vector2(2, 5), Color.White, 0f, Vector2.Zero, 0.4f, SpriteEffects.None, 0f);
            srcRect = new Rectangle(99, 39, 6, 3);
            rect    = new Rectangle(62, game.HUDHeight - 5, 6, 3);
            for (int i = 0; i < Math.Min(4, game.PlayerSmartBombs); ++i)
            {
                spriteBatch.Draw(SpriteSheet, rect, srcRect, Color.White);
                rect.Y -= srcRect.Height + 1;
            }

            Color color = Color.Blue;

            spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(70, 0, 2, game.HUDHeight + 1), color);
            spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(251, 0, 2, game.HUDHeight + 1), color);
            spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(0, game.HUDHeight + 1, game.ScreenSize.X, 1), color);

            spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(150, 0, 22, 1), Color.White);
            spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(150, 1, 1, 1), Color.White);
            spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(171, 1, 1, 1), Color.White);
            spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(150, game.HUDHeight + 1, 22, 1), Color.White);
            spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(150, game.HUDHeight, 1, 1), Color.White);
            spriteBatch.Draw(CoreGlobals.BlankTexture, new Rectangle(171, game.HUDHeight, 1, 1), Color.White);
        }