Example #1
0
        private static void DrawScoreAndLivesRect(ISpriteBatch spriteBatch)
        {
            var r = new Rectangle(342, 6, 148, 20);

            spriteBatch.DrawRectangle(r, Color.Blue);

            r.Inflate(-2, -2);
            spriteBatch.DrawRectangle(r, Color.Black);
        }
Example #2
0
        private void DrawRemainingEnergy(ISpriteBatch spriteBatch, int playerEnergy)
        {
            bool isAboutToDie = playerEnergy < 4;
            int  barLength    = isAboutToDie ? (playerEnergy + 1) << 4 : Math.Min(playerEnergy >> 2, 64);
            var  barColour    = isAboutToDie ? Color.Red : Color.Green;
            var  r            = new Rectangle(32, 12, barLength * 2, 8);

            spriteBatch.DrawRectangle(r, barColour);

#if DEBUG
            r = new Rectangle(168, 8, 28, 16);
            spriteBatch.DrawRectangle(r, Color.Black);
            DrawValue(spriteBatch, playerEnergy, 168 + 24, 8);
#endif
        }
Example #3
0
        private static void DrawEnergyRect(ISpriteBatch spriteBatch, bool isGameRunningSlowly)
        {
            // outer frame
            var r = new Rectangle(22, 6, 148, 20);

            spriteBatch.DrawRectangle(r, isGameRunningSlowly ? Color.Red : Color.Blue);

            // clear inner area
            r.Inflate(-2, -2);
            spriteBatch.DrawRectangle(r, Color.Black);

            // always start off with energy bar in blue
            r = new Rectangle(32, 12, 128, 8);
            spriteBatch.DrawRectangle(r, Color.Blue);
        }
Example #4
0
        private void DrawScoreAndLives(ISpriteBatch spriteBatch)
        {
            var r = new Rectangle(342, 6, 148, 20);
            spriteBatch.DrawRectangle(r, Color.Blue);

            r.Inflate(-2, -2);
            spriteBatch.DrawRectangle(r, Color.Black);

            DrawValue(spriteBatch, this._displayedScore, 416, 8);

            for (int i = 0; i < this._lives; i++)
                {
                Vector2 destination = new Vector2(480 - ((i + 1) * 16), 8) + spriteBatch.WindowOffset;
                spriteBatch.DrawEntireTexture(this._life, destination);
                }
        }
Example #5
0
        private void DrawEnergy(ISpriteBatch spriteBatch)
        {
            var r = new Rectangle(22, 6, 148, 20);
            spriteBatch.DrawRectangle(r, Color.Blue);

            r.Inflate(-2, -2);
            spriteBatch.DrawRectangle(r, Color.Black);

            r = new Rectangle(32, 12, 128, 8);
            spriteBatch.DrawRectangle(r, Color.Blue);

            if (!this.World.Player.IsExtant)
                return;

            bool isAboutToDie = this.World.Player.Energy < 4;
            int barLength = isAboutToDie ? (this.World.Player.Energy + 1) << 4 : Math.Min(this.World.Player.Energy >> 2, 64);
            Color barColour = isAboutToDie ? Color.Red : Color.Green;
            r = new Rectangle(32, 12, barLength * 2, 8);
            spriteBatch.DrawRectangle(r, barColour);

            #if DEBUG
            r = new Rectangle(168, 8, 28, 16);
            spriteBatch.DrawRectangle(r, Color.Black);
            DrawValue(spriteBatch, this.World.Player.Energy, 168 + 24, 8);
            #endif
        }