// Stops all movement timers on keyup private void Form1_KeyUp(object sender, KeyEventArgs e) { RightMoveTimer.Stop(); LeftMoveTimer.Stop(); UpMoveTimer.Stop(); DownMoveTimer.Stop(); }
private void Form1_KeyUp(object sender, KeyEventArgs e) { RightMoveTimer.Stop(); LeftMoveTimer.Stop(); UpMoveTimer.Stop(); DownMoveTimer.Stop(); if (e.KeyCode == Keys.Space) { if (!gameIsOver) { if (pause) { StartTimers(); label1.Visible = false; gameMedia.controls.play(); pause = false; } else { label1.Location = new Point(this.Width / 2 - 120, 150); label1.Text = "PAUSED"; label1.Visible = true; gameMedia.controls.pause(); StopTimers(); pause = true; } } } }
private void StartTimers() { LeftMoveTimer.Start(); RightMoveTimer.Start(); LaserTimer.Start(); EnemiesTimer.Start(); }
private void Form1_KeyDown(object sender, KeyEventArgs e) { if (!pause) { if (e.KeyCode == Keys.Right) { RightMoveTimer.Start(); } if (e.KeyCode == Keys.Left) { LeftMoveTimer.Start(); } if (e.KeyCode == Keys.Up) { UpMoveTimer.Start(); } if (e.KeyCode == Keys.Down) { DownMoveTimer.Start(); } if (e.KeyCode == Keys.Space) { if (currentAmmo < limAmmo) { currentAmmo++; fire = true; } } } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Down || e.KeyCode == Keys.Up) { mainPlayer.Image = Properties.Resources.cowboy_run; if (e.KeyCode == Keys.Left) { LeftMoveTimer.Start(); } if (e.KeyCode == Keys.Right) { RightMoveTimer.Start(); } if (e.KeyCode == Keys.Up) { UpMoveTimer.Start(); } if (e.KeyCode == Keys.Down) { DownMoveTimer.Start(); } } if (e.KeyCode == Keys.Space) { ShootingTimer.Start(); } if (e.KeyCode == Keys.Escape) { Process.GetCurrentProcess().Kill(); } }
// This is when key is pressed private void Form1_KeyDown(object sender, KeyEventArgs e) { if (!pause) { if (e.KeyCode == Keys.Right) { RightMoveTimer.Start(); } if (e.KeyCode == Keys.Left) { LeftMoveTimer.Start(); } if (e.KeyCode == Keys.Down) { DownMoveTimer.Start(); } if (e.KeyCode == Keys.Up) { UpMoveTimer.Start(); } } }
private void Form1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Down || e.KeyCode == Keys.Up) { mainPlayer.Image = Properties.Resources.cowboy; if (e.KeyCode == Keys.Left) { LeftMoveTimer.Stop(); } if (e.KeyCode == Keys.Right) { RightMoveTimer.Stop(); } if (e.KeyCode == Keys.Up) { UpMoveTimer.Stop(); } if (e.KeyCode == Keys.Down) { DownMoveTimer.Stop(); } } if (e.KeyCode == Keys.Space) { ShootingTimer.Stop(); } }
private void ReplayBtn_Click(object sender, EventArgs e) { this.Controls.Clear(); InitializeComponent(); Form1_Load(e, e); RightMoveTimer.Stop(); LeftMoveTimer.Stop(); DownMoveTimer.Stop(); UpMoveTimer.Stop(); }
private void StopTimers() { MoveBgTimer.Stop(); EnemiesMoveTimer.Stop(); UpMoveTimer.Stop(); DownMoveTimer.Stop(); LeftMoveTimer.Stop(); RightMoveTimer.Stop(); moveMunitionTimer.Stop(); munitionCreate.Stop(); }
private void StopTimers() { MoveBgTimer.Stop(); MoveEnemiesTimer.Stop(); MoveAmmunitionTimer.Stop(); EnemiesAmmunitionTimer.Stop(); LeftMoveTimer.Stop(); RightMoveTimer.Stop(); UpMoveTimer.Stop(); DownMoveTimer.Stop(); }
private void StartTimers() { int milliseconds = 2000; Thread.Sleep(milliseconds); LeftMoveTimer.Start(); RightMoveTimer.Start(); UpMoveTimer.Start(); DownMoveTimer.Start(); MoveBgTimer.Start(); MoveEnemiesTimer.Start(); MoveAmmunitionTimer.Start(); EnemiesAmmunitionTimer.Start(); }
private void Form1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Right) { RightMoveTimer.Stop(); } if (e.KeyCode == Keys.Left) { LeftMoveTimer.Stop(); } if (e.KeyCode == Keys.Up) { k = 1; Player.Image = Image.FromFile(@"imagini\me1.png"); UpMoveTimer.Stop(); } if (e.KeyCode == Keys.Down) { DownMoveTimer.Stop(); } if (e.KeyCode == Keys.Escape) { if (!gameIsOver) { if (pause) { StartTimers(); label1.Visible = false; gameMedia.controls.play(); pause = false; } else { label1.Location = new Point(this.Width / 2 - 120, 150); label1.Text = "Paused"; label1.Visible = true; gameMedia.controls.pause(); StopTimers(); pause = true; } } } }
private void Form1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up) { UpMoveTimer.Stop(); } if (e.KeyCode == Keys.Down) { DownMoveTimer.Stop(); } if (e.KeyCode == Keys.Left) { LeftMoveTimer.Stop(); } if (e.KeyCode == Keys.Right) { RightMoveTimer.Stop(); } if (e.KeyCode == Keys.Space) { if (!gameIsOver) { if (pause) { labelGameOver.Visible = false; pictureBoxControls.Visible = false; pause = false; StartTimers(); // MessageBox.Show("game unpaused"); } else { labelGameOver.Text = " PAUSE"; labelGameOver.Visible = true; pictureBoxControls.Visible = true; pause = true; StopTimers(); // MessageBox.Show("game paused"); } } } }
public void Form1_KeyUp(object sender, KeyEventArgs e) { RihtMoveTimer.Stop(); LeftMoveTimer.Stop(); BackMoveTimer.Stop(); ForwardMoveTimer.Stop(); if (firstPlane) { Player.Image = Properties.Resources.Plane_1_place; } else if (secondPlane) { Player.Image = Properties.Resources.Plane_2_place; } else if (thirdPlane) { Player.Image = Properties.Resources.Plane_3_place; } }
public void gameover() { RihtMoveTimer.Stop(); LeftMoveTimer.Stop(); BackMoveTimer.Stop(); ForwardMoveTimer.Stop(); enemyMoveTimer.Stop(); isDead = true; Player.Visible = false; Play.Enabled = false; ReplayButton.Visible = true; ReplayButton.Enabled = true; PointsLabel.Visible = false; for (int i = 0; i < stars.Length; i++) { stars[i].Visible = false; } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Left) { if (Spaceship.spaceshipX > 20) { LeftMoveTimer.Start(); } else { LeftMoveTimer.Stop(); Spaceship.spaceshipV = 0; } } if (e.KeyCode == Keys.Right) { if (Spaceship.spaceshipX < 580) { RightMoveTimer.Start(); } else { RightMoveTimer.Stop(); Spaceship.spaceshipV = 0; } } if (e.KeyCode == Keys.Space) { LaserTimer.Start(); } if (e.KeyCode == Keys.R) { ResetGame(); } }
private void SpaceUFO_KeyUp(object sender, KeyEventArgs e) { RightMoveTimer.Stop(); LeftMoveTimer.Stop(); DownMoveTimer.Stop(); UpMoveTimer.Stop(); if (e.KeyCode == Keys.Escape) // press esc then escape from the game { Environment.Exit(1); } if (e.KeyCode == Keys.Space) // Press space to pause { if (!GameIsOver) { if (pause) // pause = false { StartTimers(); label.Visible = false; gameMedia.controls.play(); pause = false; } else { label.Location = new Point(this.Width / 2 - 60, 250); label.Text = "PAUSE"; label.Visible = true; gameMedia.controls.pause(); StopTimers(); pause = true; } } } }
private void GameOver(string str) { gameMedia.controls.stop(); playerexplosion.controls.play(); gameover_sound.controls.play(); label.Visible = true; label.Text = str.Trim(); pictureBox2.Visible = false; ReplayButton.Visible = true; QUITTER.Visible = true; // Graphics g = this.CreateGraphics(); // drawing a string Font myFont = new Font("Fixedsys", 10); g.DrawString("1", myFont, Brushes.Gray, 100, 100); // erasing a string g.DrawString("1", myFont, Brushes.Black, 100, 100); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel; //pause = false; // //PlayerSpeed = 0; //Reset of the game parameters PlayerSpeed = 4; MunitionsSpeed = 20; enemiesSpeed = 4; enemiesMunitionSpeed = 4; StopTimers(); RightMoveTimer.Stop(); LeftMoveTimer.Stop(); DownMoveTimer.Stop(); UpMoveTimer.Stop(); }
private void Form1_KeyUp(object sender, KeyEventArgs e) { RightMoveTimer.Stop(); LeftMoveTimer.Stop(); Spaceship.spaceshipV = 0; }
public void Form1_KeyDown(object sender, KeyEventArgs e) // Function that performs movements in 2D space for 3 models of spacecraft { e.SuppressKeyPress = true; if (!paused) { switch (e.KeyCode) { case Keys.D: // Button D if (firstPlane) { Player.Image = Properties.Resources.Plane_1_right; } else if (secondPlane) { Player.Image = Properties.Resources.Plane_2_right; } else if (thirdPlane) { Player.Image = Properties.Resources.Plane_3_right; } RihtMoveTimer.Start(); break; case Keys.A: // Button A if (firstPlane) { Player.Image = Properties.Resources.Plane_1_left; } else if (secondPlane) { Player.Image = Properties.Resources.Plane_2_left; } else if (thirdPlane) { Player.Image = Properties.Resources.Plane_3_left; } LeftMoveTimer.Start(); break; case Keys.S: // Button S if (firstPlane) { Player.Image = Properties.Resources.Plane_1_down; } else if (secondPlane) { Player.Image = Properties.Resources.Plane_2_place; } else if (thirdPlane) { Player.Image = Properties.Resources.Plane_3_down; } BackMoveTimer.Start(); break; case Keys.W: // Button W if (firstPlane) { Player.Image = Properties.Resources.Plane_1_up; } else if (secondPlane) { Player.Image = Properties.Resources.Plane_2_up; } else if (thirdPlane) { Player.Image = Properties.Resources.Plane_3_up; } ForwardMoveTimer.Start(); break; case Keys.Space: //Button Space if (!isDead) { if (paused) { StartTimers(); } else { ShootSound.controls.play(); MoveBullets(); } } break; case Keys.P: if (isstarted) { StopTimers(); Menu_On(); } break; } } else { if (e.KeyCode == Keys.C) { if (isstarted) { StartTimers(); Menu_Off(); } } } }