Ejemplo n.º 1
0
        /// <summary>
        /// Render invaders to the canvas.
        /// </summary>
        /// <param name="graphics"></param>
        /// <returns></returns>
        public InvadersController RenderInvaders(Graphics graphics)
        {
            for (int i = 0; i < _invadersPos.Height; ++i)
            {
                for (int j = 0; j < _invadersPos.Width; ++j)
                {
                    Invader invader = _invaders[i, j];
                    if (invader != null)
                    {
                        float x = (_invadersPos.X + _invaderSize.Width * j) * _scale;
                        float y = (_invadersPos.Y + _invaderSize.Height * i) * _scale;

                        invader.Render(graphics, x, y, _scale, _invaderStepps);
                    }
#if DEBUG
                    else
                    {
                        float x = (_invadersPos.X + _invaderSize.Width * j) * _scale;
                        float y = (_invadersPos.Y + _invaderSize.Height * i) * _scale;

                        float width  = (_invaderSize.Width - 1) * _scale;
                        float height = (_invaderSize.Height - 1) * _scale;

                        graphics.DrawRectangle(Pens.Gray, x, y, width, height);
                        graphics.DrawLine(Pens.Gray, x, y, x + width, y + height);
                        graphics.DrawLine(Pens.Gray, x, y + height, x + width, y);
                    }
#endif
                }
            }

            return(this);
        }
Ejemplo n.º 2
0
        public InvadersController RenderPaddle(Graphics graphics)
        {
            _paddle.Render(graphics, _paddlePos.X * _scale, _paddlePos.Y * _scale, _scale, 0);
            if (!_projectrilePos.IsEmpty)
            {
                _projectile.Render(graphics, _projectrilePos.X * _scale, _projectrilePos.Y * _scale, _scale, 0);
            }

            return(this);
        }