private void gameTimer_Tick(object sender, EventArgs e) { this.Focus(); // Start counter countdown to enable a bullet timer between each shot counter--; scoreCounter--; // Movement for player, also changes the direction of the image if (leftArrowDown) { Pl.move(Pl, "Left"); direction = 1; } else if (rightArrowDown) { Pl.move(Pl, "Right"); direction = 0; } if (upArrowDown) { Pl.move(Pl, "Up"); } else if (downArrowDown) { Pl.move(Pl, "Down"); } //Enemy movement towards player if (Pl.x > En.x) { En.move(En, "Right"); collisionCheck = 1; if (Pl.y > En.y) { En.move(En, "Down"); collisionCheck = 2; } if (Pl.y < En.y) { En.move(En, "Up"); collisionCheck = 3; } } if (Pl.x < En.x) { En.move(En, "Left"); collisionCheck = 4; if (Pl.y < En.y) { En.move(En, "Up"); collisionCheck = 3; } if (Pl.y > En.y) { En.move(En, "Down"); collisionCheck = 2; } } // Bullet fire for the player if (spaceArrowDown && counter < 0) { //Check if player is moving left if (direction == 0) { Bullets Bs = new Bullets(Pl.x + 32, Pl.y + 35, 2, 7, "Right"); bullets.Add(Bs); counter = 12; } //Check if player is moving right else if (direction == 1) { Bullets Bs = new Bullets(Pl.x, Pl.y + 35, 2, 7, "Left"); bullets.Add(Bs); counter = 12; } } //foreach bullet b - b.move(b); foreach (Bullets Bs in bullets) { Bs.move(Bs); } //Adds score over time if (scoreCounter < 0) { currentScore++; scoreNumber.Text = "1" + currentScore; scoreCounter = 30; } //Check if the enemy hits the player foreach (Enemy En in enemys) { if (Pl.collision(Pl, En) == true) { Application.Exit(); } } //if ( ) //{ // Application.Exit(); //} Refresh(); }