Example #1
0
        public override void Draw()
        {
            if (_visible)
            {
                if (_thrustAnimActive)
                {
                    DrawThrust();
                }

                //Here's where the actual ship gets drawn
                double directionInRadians = (Math.PI * _direction) / 180;

                float x1 = _x + (SHIP_HEIGHT * (float)Math.Sin(directionInRadians));
                float y1 = _y - (SHIP_HEIGHT * (float)Math.Cos(directionInRadians));

                float x2 = _x + (SHIP_WIDTH * (float)Math.Cos(directionInRadians));
                float y2 = _y + (SHIP_WIDTH * (float)Math.Sin(directionInRadians));

                float x3 = _x - (SHIP_WIDTH * (float)Math.Cos(directionInRadians));
                float y3 = _y - (SHIP_WIDTH * (float)Math.Sin(directionInRadians));

                _shape = SwinGame.CreateTriangle(x1, y1, x2, y2, x3, y3);

                SwinGame.FillTriangle(_colour, _shape);
            }
            if (_visible || (_mercyTimer > 0))
            {
                _missiles.DrawAll();
            }
            //Draws life counter next to ship during the mercy period after respawning
            if ((_mercyTimer > 0) && (LivesEnabled))
            {
                SwinGame.DrawText(string.Format("x " + _lives), _colour, SwinGame.FontNamed("tinyFont"), _x + 40, _y - 10);
            }
            //Draws explosion animation if the player is dead
            if (_respawnTimer > RESPAWN_LENGTH - 90)
            {
                if (_respawnTimer % 10 >= 5)
                {
                    SwinGame.DrawCircle(Color.Red, _x, _y, 10);
                    SwinGame.DrawCircle(_colour, _x, _y, 20);
                }
                if (_respawnTimer % 10 < 5)
                {
                    SwinGame.DrawCircle(_colour, _x, _y, 15);
                    SwinGame.DrawCircle(Color.Red, _x, _y, 25);
                }
            }
        }