private List <AlienRay> AlienRays = new List <AlienRay>(); // Dynamic list of alien rays private void Form1_Load(object sender, EventArgs e) { playerIcon = new Canon(25, 15, (this.picCanvas.Width / 2), (this.picCanvas.Height - 25)); // Create multiple array lists that represent the waves of aliens that come towards the player: int offsetX = 0; // Set offset value List <Alien> row1 = new List <Alien>(); for (int i = 0; i < 8; i++) { row1.Add(new Alien(25, 50, offsetX, 0)); offsetX += 70; } Aliens.Add(row1); offsetX = 0; // Reset offset value List <Alien> row2 = new List <Alien>(); for (int i = 0; i < 8; i++) { row2.Add(new Alien(25, 50, offsetX, 50)); offsetX += 70; } Aliens.Add(row2); offsetX = 0; // Reset offset value List <Alien> row3 = new List <Alien>(); for (int i = 0; i < 8; i++) { row3.Add(new Alien(25, 50, offsetX, 100)); offsetX += 70; } Aliens.Add(row3); offsetX = 0; // Reset offset value List <Alien> row4 = new List <Alien>(); for (int i = 0; i < 8; i++) { row4.Add(new Alien(25, 50, offsetX, 150)); offsetX += 70; } Aliens.Add(row4); // Set up the different shelters: int shelterOffsetX = this.picCanvas.Width / 9; for (int i = 0; i < 4; i++) { Shelters.Add(new Shelter(100, 25, shelterOffsetX, this.picCanvas.Height - 100)); shelterOffsetX += 200; } // Set up timer to control game: Timer timer = new Timer(); timer.Interval = 10; timer.Tick += new EventHandler(timer_Tick); timer.Start(); }
private void initGame() { this.playerIcon = new Canon(25, 15, (this.picCanvas.Width / 2), (this.picCanvas.Height - 25)); this.aliens = new List <Alien>(); this.bullets = new List <Bullet>(); // Create multiple array lists that represent the waves of aliens that come towards the player: int currentY = 0; for (int i = 0; i < 8; i++) //Y { int offsetX = this.picCanvas.Width / 12; for (int j = 0; j < 8; j++) //X { this.aliens.Add(new Alien(25, 50, offsetX += 100, currentY)); } currentY += 50; } // Set up timer to control game: Timer timer = new Timer() { Interval = 10 }; timer.Tick += timer_Tick; timer.Start(); //List<Alien> row1 = new List<Alien>(); //for (int i = 0; i < 8; i++) //{ // row1.Add(new Alien(25, 50, offsetX, 0)); // offsetX += 100; //} //this.aliens.Add(row1); //offsetX = this.picCanvas.Width / 12; //List<Alien> row2 = new List<Alien>(); //for (int i = 0; i < 8; i++) //{ // row2.Add(new Alien(25, 50, offsetX, 50)); // offsetX += 100; //} //Aliens.Add(row2); //offsetX = this.picCanvas.Width / 12; //List<Alien> row3 = new List<Alien>(); //for (int i = 0; i < 8; i++) //{ // row3.Add(new Alien(25, 50, offsetX, 100)); // offsetX += 100; //} //Aliens.Add(row3); //offsetX = this.picCanvas.Width / 12; //List<Alien> row4 = new List<Alien>(); //for (int i = 0; i < 8; i++) //{ // row4.Add(new Alien(25, 50, offsetX, 150)); // offsetX += 100; //} //Aliens.Add(row4); }