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); }
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; }
public static Asteroid Create(Field field) { return new Asteroid(field); }
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; }
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); }
public static Star Create(Field field) { return new Star(field); }
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); }
public static Rocket Create(Field field) { return new Rocket(field); }