private void addStar(Random random) { int height = formArea.Height; int width = formArea.Width; Point location = new Point(random.Next(0, width), random.Next(0, height)); Star newStar = new Star(location, Brushes.Yellow); stars.Add(newStar); }
public Game(Main MainForm) { deadTimer.Interval = 3000; deadTimer.Tick += new EventHandler(deadTimer_Tick); deadTimer.Enabled = false; this.MainForm = MainForm; windowBoundaries = new Rectangle(0, 0, this.MainForm.Width, this.MainForm.Height); playableBoundaries = new Rectangle(0, 0, windowBoundaries.Width - leftRightPadding, windowBoundaries.Height - leftRightPadding); invaders = new List<Invader>(); createInvaders(); invaderShots = new List<Shot>(); createPlayerShip(); playerShots = new List<Shot>(); star = new Star(new Point(random.Next(0, windowBoundaries.Width), random.Next(0, windowBoundaries.Height)), new Pen(Color.DarkMagenta), windowBoundaries); using (Graphics g = this.MainForm.CreateGraphics()) { star.Draw(g); } }