Esempio n. 1
0
 private Asteroid(Field field)
 {
     this.field = field;
     //place in the exact center, to start
     this.y_pos = rand.Next(field.Left, field.Width);
     this.x_pos = rand.Next(field.Top, field.Height);
 }
Esempio n. 2
0
 private Rocket(Field field)
 {
     this.field = field;
     //place in the exact center, to start
     this.y_pos = (field.Height - field.Top) / 2;
     this.x_pos = (field.Width - field.Left) / 2;
     this.Radius = 10;
 }
Esempio n. 3
0
 public static Asteroid Create(Field field)
 {
     return new Asteroid(field);
 }
Esempio n. 4
0
        private void StartGame()
        {
            this.Wave = 1;
            this.messageLabel.Visible = false;
            this.messageLabel.Top = this.Height / 2;
            this.messageLabel.Left = this.Width / 2;
            this.Lives = 3;
            this.Score = 0;

            const int PADDING = 25;
            this.field = Field.create(this.Top + PADDING, this.Left + PADDING, this.Height - PADDING, this.Width - PADDING);
            rocketItem = Rocket.Create(this.field);
            rocketItem.Radius = 10;

            const int ASTEROID_SIZE = 60;
            const int ASTEROID_COUNT = 7;

            CurrentWaveCount = ASTEROID_COUNT;
            this.CurrentWaveSize = ASTEROID_SIZE;
            this.CreateAsteroidWave(ASTEROID_COUNT, ASTEROID_SIZE);
            this.starCollection.Clear();
            this.bulletCollection.Clear();
            const int STAR_COUNT = 55;
            for (int i = 0; i < STAR_COUNT; i++)
            {
                Star star = Star.Create(this.field);
                starCollection.Add(star);
            }
            this.IsGameOn = true;
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
 public static Star Create(Field field)
 {
     return new Star(field);
 }
Esempio n. 7
0
 private Star(Field field)
 {
     this.field = field;
     this.x_pos = rand.Next(field.Left, field.Width);
     this.y_pos = rand.Next(field.Top, field.Height);
 }
Esempio n. 8
0
 public static Rocket Create(Field field)
 {
     return new Rocket(field);
 }