Пример #1
0
        private void ComposePauseShowLevel(CompositionTargetBase target)
        {
            //draw a big bordered box
            target.FillRectangle(
                Brushes.Black,
                this._rectAlert);

            target.DrawRectangle(
                Pens.Lime,
                this._rectAlert);

            //draw a "Level" abbreviation
            target.DrawString(
                "Lv",
                Fonts.Fixed5x7,
                Brushes.Lime,
                this._rectAlert.Left + 2,
                this._rectAlert.Top + 2);

            //draw the number of the current level
            string text = this.Context.CurrentLevel.ToString();
            Size   sz   = target.MeasureString(text, Fonts.Fixed5x7);

            target.DrawString(
                text,
                Fonts.Fixed5x7,
                Brushes.Yellow,
                this._rectAlert.Right - 2 - sz.Width,
                this._rectAlert.Top + 2);
        }
Пример #2
0
        private void ComposePauseSaucerHit(CompositionTargetBase target)
        {
            //draw a big bordered box
            target.FillRectangle(
                Brushes.Black,
                this._rectAlert);

            target.DrawRectangle(
                Pens.Lime,
                this._rectAlert);

            //draw the ship symbol
            target.DrawString(
                "LM",   //saucer
                AlienFont.Instance,
                Brushes.Lime,
                this._rectAlert.Left,
                this._rectAlert.Top + 2);

            //draw the number of ships left
            string text = this.Saucer.PromisedScore.ToString();
            Size   sz   = target.MeasureString(text, Fonts.Fixed5x7);

            target.DrawString(
                text,
                Fonts.Fixed5x7,
                Brushes.Yellow,
                this._rectAlert.Right - 2 - sz.Width,
                this._rectAlert.Top + 2);
        }
Пример #3
0
        public void OnRender(CompositionTargetBase target)
        {
            //render the ball as a square at the current position
            this._rect.X = (int)(this._xpos + 0.5f);
            this._rect.Y = (int)(this._ypos + 0.5f);

            target.FillRectangle(
                this._brush,
                this._rect);

            target.DrawRectangle(
                this._pen,
                this._rect);

            //move the ball according to its speed
            this._xpos += this._xspeed;
            this._ypos += this._yspeed;

            //checks the viewport edges and makes the ball bouncing
            if (this._rightBound == 0)
            {
                Size vp = target.ViewportSize;
                this._rightBound  = vp.Width - EdgeLength;
                this._bottomBound = vp.Height - EdgeLength;
            }

            if (this._xpos < 0)
            {
                this._xspeed = -this._xspeed;
                this._xpos  += this._xspeed;
            }
            else if (this._xpos >= this._rightBound)
            {
                this._xspeed = -this._xspeed;
                this._xpos  += this._xspeed;
            }

            if (this._ypos < 0)
            {
                this._yspeed = -this._yspeed;
                this._ypos  += this._yspeed;
            }
            else if (this._ypos >= this._bottomBound)
            {
                this._yspeed = -this._yspeed;
                this._ypos  += this._yspeed;
            }
        }
Пример #4
0
        private void ComposePauseGameOver(CompositionTargetBase target)
        {
            //draw a big bordered box
            target.FillRectangle(
                Brushes.Black,
                this._rectAlert);

            target.DrawRectangle(
                Pens.Lime,
                this._rectAlert);

            //draw "game" then "over"
            var text = (this._pausedClock > PausedTimeShort)
                ? "GAME"
                : "OVER";

            target.DrawString(
                text,
                Fonts.Fixed5x7,
                Brushes.Red,
                this._rectAlert.Left + 2,
                this._rectAlert.Top + 2);
        }
Пример #5
0
        private static void TestColors()
        {
            //draw a couple of rectangle frames as background,
            //so that the transparency will be easy to test
            var rect = new Rectangle(2, 2, 27, 11);

            _composition.DrawRectangle(
                Pens.Lime,
                rect);

            rect.Inflate(-4, -4);
            _composition.DrawRectangle(
                Pens.Lime,
                rect);

            //draw many colored blocks as much the colors are
            rect = new Rectangle(0, 0, 7, 3);

            //opaque colors
            _composition.FillRectangle(new SolidBrush(Colors.Black), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.Blue), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.Lime), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.Aqua), rect);
            rect.X += 8;
            rect.Y  = 0;
            _composition.FillRectangle(new SolidBrush(Colors.Red), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.Fuchsia), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.Yellow), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.White), rect);
            rect.X += 8;
            rect.Y  = 0;

            //transparent colors
            _composition.FillRectangle(new SolidBrush(Colors.Black & ~Colors.Opaque), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.Blue & ~Colors.Opaque), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.Lime & ~Colors.Opaque), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.Aqua & ~Colors.Opaque), rect);
            rect.X += 8;
            rect.Y  = 0;
            _composition.FillRectangle(new SolidBrush(Colors.Red & ~Colors.Opaque), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.Fuchsia & ~Colors.Opaque), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.Yellow & ~Colors.Opaque), rect);
            rect.Y += 4;
            _composition.FillRectangle(new SolidBrush(Colors.White & ~Colors.Opaque), rect);
        }