public void DrawPowerup(Powerup powerup, PaintEventArgs e, int worldSize)
        {
            double posX = powerup.Location.GetX();
            double posY = powerup.Location.GetY();

            DrawingTransformer.DrawObjectWithTransform(e, powerup, worldSize, posX, posY, 0, DrawPowerupSprite);
        }
Beispiel #2
0
        public void DrawProjectile(Projectile projectile, PaintEventArgs e, int worldSize)
        {
            double posX = projectile.Location.GetX();
            double posY = projectile.Location.GetY();

            projectile.Direction.Normalize();
            double angle = projectile.Direction.ToAngle();

            if (Double.IsNaN(posX) || Double.IsNaN(posY) || Double.IsNaN(angle))
            {
                return;
            }
            DrawingTransformer.DrawObjectWithTransform(e, projectile, worldSize, posX, posY, angle, DrawProjectileSprite);
        }
Beispiel #3
0
        public void DrawTank(Tank tank, PaintEventArgs e, int worldSize)
        {
            DrawingTransformer.DrawObjectWithTransform(e, tank, worldSize, tank.Location.GetX(), tank.Location.GetY(), tank.BodyDirection.ToAngle(), DrawTankBody);
            tank.TurretDirection.Normalize();
            double angle = tank.TurretDirection.ToAngle();

            if (Double.IsNaN(angle))
            {
                // this prevents the game from crashing when you put your mouse in the middle of the tank
                angle = 0;
            }
            DrawingTransformer.DrawObjectWithTransform(e, tank, worldSize, tank.Location.GetX(), tank.Location.GetY(), angle, DrawTankTurret);
            DrawingTransformer.DrawObjectWithTransform(e, tank, worldSize, tank.Location.GetX(), tank.Location.GetY(), 0, DrawTankName);
            DrawingTransformer.DrawObjectWithTransform(e, tank, worldSize, tank.Location.GetX(), tank.Location.GetY(), 0, DrawTankHealth);
        }
Beispiel #4
0
        public void DrawBeam(Beam beam, PaintEventArgs e, int worldSize)
        {
            double posX = beam.Origin.GetX();
            double posY = beam.Origin.GetY();

            beam.Direction.Normalize();
            double angle = beam.Direction.ToAngle();

            angle += 180;  // rotate 180 degrees
            if (Double.IsNaN(posX) || Double.IsNaN(posY) || Double.IsNaN(angle))
            {
                return;
            }
            DrawingTransformer.DrawObjectWithTransform(e, beam, worldSize, posX, posY, angle, DrawBeamSprite);
        }
Beispiel #5
0
        private void DrawHorizontalWall(Wall wall, PaintEventArgs e, int worldSize)
        {
            double posY          = wall.EndPoint1.GetY(); // Y position will always be the same
            double leftmostPosX  = Math.Min(wall.EndPoint1.GetX(), wall.EndPoint2.GetX());
            double rightmostPosX = Math.Max(wall.EndPoint1.GetX(), wall.EndPoint2.GetX());
            // The length between p1 and p2 will always be a multiple of the wall width (50 units).
            int numWallBlocksToDraw = Convert.ToInt32((rightmostPosX - leftmostPosX) / wallSize);

            for (int i = 0; i <= numWallBlocksToDraw; i++)
            {
                double offset = wallSize * i;
                double posX   = leftmostPosX + offset;
                DrawingTransformer.DrawObjectWithTransform(e, wall, worldSize, posX, posY, 0, DrawWallBlock);
            }
        }
Beispiel #6
0
        private void DrawVerticalWall(Wall wall, PaintEventArgs e, int worldSize)
        {
            double posX        = wall.EndPoint1.GetX(); // X position will always be the same
            double lowestPosY  = Math.Min(wall.EndPoint1.GetY(), wall.EndPoint2.GetY());
            double highestPosY = Math.Max(wall.EndPoint1.GetY(), wall.EndPoint2.GetY());
            // The length between p1 and p2 will always be a multiple of the wall width (50 units).
            int numWallBlocksToDraw = Convert.ToInt32((highestPosY - lowestPosY) / wallSize);

            for (int i = 0; i <= numWallBlocksToDraw; i++)
            {
                double offset = wallSize * i;
                double posY   = lowestPosY + offset;
                // TODO how should we get the gameWorld size?
                DrawingTransformer.DrawObjectWithTransform(e, wall, worldSize, posX, posY, 0, DrawWallBlock);
            }
        }
 public void DrawExplosion(Tank tank, PaintEventArgs e, int worldSize)
 {
     DrawingTransformer.DrawObjectWithTransform(e, tank, worldSize, tank.Location.GetX(), tank.Location.GetY(), 0, DrawExplosionSprite);
 }