private void GameOver() { TimerAnimate.Stop(); TimerMove.Stop(); heroImageCount = 0; TimerHeroMelt.Start(); }
private void SetUpGame() { this.BackColor = Color.Blue; Hero.BackColor = Color.Transparent; Hero.SizeMode = PictureBoxSizeMode.StretchImage; Hero.Width = 50; Hero.Height = 50; Food.BackColor = Color.Transparent; Food.Image = Properties.Resources.food_1; RandomizeFood(); Food.SizeMode = PictureBoxSizeMode.StretchImage; Enemy.BackColor = Color.Transparent; Enemy.SizeMode = PictureBoxSizeMode.StretchImage; Enemy.Height = 40; Enemy.Width = 40; // starting timer TimerMove.Start(); TimerAnimate.Start(); // score UpdateScoreLabel(); randomChangeEnemyDirection(); }
private void SetUpGame() { this.BackColor = Color.Blue; Hero.BackColor = Color.Transparent; Hero.SizeMode = PictureBoxSizeMode.StretchImage; Hero.Width = 50; Hero.Height = 50; Food.BackColor = Color.Transparent; Food.SizeMode = PictureBoxSizeMode.StretchImage; Food.Image = Properties.Resources.food_1; RandomizeFood(); Enemy.BackColor = Color.Transparent; Enemy.SizeMode = PictureBoxSizeMode.StretchImage; Enemy.Height = 40; Enemy.Width = 40; //set up interface UpdateScoreLabel(); //starging timers TimerMove.Start(); TimerAnimate.Start(); RandomChangeEnemyDirection(); GameOverBox.Visible = false; try { SoundPlayer sndPlayer = new SoundPlayer(Properties.Resources.med_coffin_dance); sndPlayer.Play(); } catch (Exception ex) { MessageBox.Show("Error Message - " + ex.Message); } }
private void Game_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.W) { verVelocity = -heroStep; horVelocity = 0; heroDirection = "up"; } else if (e.KeyCode == Keys.S) { verVelocity = heroStep; horVelocity = 0; heroDirection = "down"; } else if (e.KeyCode == Keys.A) { verVelocity = 0; horVelocity = -heroStep; heroDirection = "left"; } else if (e.KeyCode == Keys.D) { verVelocity = 0; horVelocity = heroStep; heroDirection = "right"; } else if (e.KeyCode == Keys.P) { if (!gamePaused) { TimerAnimate.Stop(); TimerMove.Stop(); gamePaused = true; } else { TimerAnimate.Start(); TimerMove.Start(); gamePaused = false; } } RandomChangeEnemyDirection(); }
private void Game_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up) { verVelocity = -heroStep; horVelocity = 0; heroDirection = "up"; } else if (e.KeyCode == Keys.Down) { verVelocity = heroStep; horVelocity = 0; heroDirection = "down"; } else if (e.KeyCode == Keys.Left) { horVelocity = -heroStep; verVelocity = 0; heroDirection = "left"; } else if (e.KeyCode == Keys.Right) { horVelocity = heroStep; verVelocity = 0; heroDirection = "right"; } else if (e.KeyCode == Keys.P) // noepiezot P ir pauze { if (!gamePaused) { TimerAnimate.Stop(); TimerMove.Stop(); gamePaused = true; } else { TimerAnimate.Start(); TimerMove.Start(); gamePaused = false; } } randomChangeEnemyDirection(); }