Ejemplo n.º 1
0
 protected int GetBrightnes(SpaceItem item)
 {
     int distance = item.GetDistance(rocketItem);
     int brightness = 100 - (int)(distance / 3.5);
     if (brightness < 0)
     {
         brightness = 0;
     }
     return brightness;
 }
Ejemplo n.º 2
0
        private Bullet(SpaceItem firedFrom)
        {
            //to used in friendly-fire collision detection
            this.firedFrom=firedFrom;

            this.field = firedFrom.field;
            this._rotation = firedFrom.Rotation;
            this.Thrust();

            //add in the inertia of the thing I was fired from
            //makes the physics look more realistic
            this.x_speed = this.x_speed + firedFrom.x_speed;
            this.y_speed = this.y_speed + firedFrom.y_speed;

            this.x_pos = firedFrom.X;
            this.y_pos = firedFrom.Y;

            //place in the exact center, to start
            this.Radius = 3;
        }
Ejemplo n.º 3
0
        private Point rotatePoint(Point point, SpaceItem item)
        {
            Point rotated = new Point();
            Point origin = new Point(item.X, item.Y);
            double radians = item.Rotation / 57.32;

            rotated.X = origin.X + (int)(Math.Cos(radians) * (point.X - origin.X) -
                Math.Sin(radians) * (point.Y - origin.Y) );

            rotated.Y = origin.Y + (int)(Math.Sin(radians) * (point.X - origin.X) +
                Math.Cos(radians) * (point.Y - origin.Y));

            return rotated;
        }
Ejemplo n.º 4
0
 private Point[] getRotatedPoints(Point[] points, SpaceItem item)
 {
     Point[] rotatedPoints = new Point[points.Length];
     for (int index = 0; index < points.Length; index++)
     {
         rotatedPoints[index] = rotatePoint(points[index], item);
     }
     return rotatedPoints;
 }
Ejemplo n.º 5
0
 private Point[] getRelativePoints(Point[] points, SpaceItem item)
 {
     Point[] adjustedPoints = new Point[points.Length];
     for (int index = 0; index < points.Length; index++)
     {
         adjustedPoints[index] = new Point(points[index].X + item.X, points[index].Y + item.Y);
     }
     return adjustedPoints;
 }
Ejemplo n.º 6
0
        private void DrawSpaceItem(Graphics g, SpaceItem item, Field field, int brightness)
        {
            double scale = brightness / 100.0;
            int newRed = (int)(item.ItemColor.R * scale);
            int newGreen = (int)(item.ItemColor.G * scale);
            int newBlue = (int)(item.ItemColor.B * scale);

            Color penColor = Color.FromArgb(newRed, newGreen, newBlue);
            Pen pen = new Pen(penColor);

            Point[] points = item.EdgePoints;
            Point[] relativePoints = getRelativePoints(points, item);
            Point[] rotatedPoints = getRotatedPoints(relativePoints, item);

            g.DrawLines(pen, rotatedPoints);
        }
Ejemplo n.º 7
0
        public override void Collide(SpaceItem item)
        {
            this.DrawColor = Color.Red;

            Console.Beep();
        }
Ejemplo n.º 8
0
 public static Bullet Create(SpaceItem firedFrom)
 {
     return new Bullet(firedFrom);
 }
Ejemplo n.º 9
0
 public bool CheckCollision(SpaceItem otherItem)
 {
     int distance = GetDistance(otherItem);
     if (distance <= this.radius + otherItem.Radius)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 10
0
 public int GetDistance(SpaceItem otherItem)
 {
     int x_gap = Math.Abs(this.X - otherItem.X);
     int y_gap = Math.Abs(this.Y - otherItem.Y);
     return (int)Math.Sqrt((x_gap * x_gap) + (y_gap * y_gap));
 }
Ejemplo n.º 11
0
 public virtual void Collide(SpaceItem item)
 {
 }