public void InputDown(KeyEventArgs Key) { //for each key check if they are clicked if (Key.KeyCode == Keys.W) { U = true; } if (Key.KeyCode == Keys.S) { D = true; } if (Key.KeyCode == Keys.A) { L = true; } if (Key.KeyCode == Keys.D) { R = true; } if (Key.KeyCode == Keys.Space) { //player shoots a maximum of 5 bullets at a time if (List.Bullets.Count < 5 && EnableShoot) { List.Bullets.Add(new Bullet(Form)); Sound.ChangeSoundURL("Fire.mp3"); Sound.PlaySound(); } } }
//overloaded constructor public frmGame(int Level) { InitializeComponent(); List.player = new Player(this); LevelCounter = Level; DestroyEverything(); SpawnEnemies(); Sound.ChangeSoundURL("Fire.mp3"); Sound.ChangeMusicURL("Game.mp3"); lblLevel.Text = "Level " + Level; }
//constructor for game form public frmGame() { InitializeComponent(); List.player = new Player(this); LevelCounter = 0; DestroyEverything(); SpawnEnemies(); Sound.ChangeSoundURL("Fire.mp3"); Sound.ChangeMusicURL("Game.mp3"); if (!File.Exists("Level.txt")) { using (StreamWriter sw = File.CreateText("Level.txt")) { sw.Write("1"); } } }
private void GameOver() { //turn off all timers tmrShooting.Enabled = false; tmrEnemy.Enabled = false; tmrMovement.Enabled = false; //output You Lose Display("YOU LOSE!\nGo Back Home", lblOutput); Sound.StopMusic(); Sound.ChangeSoundURL("GameOver.mp3"); Sound.PlaySound(); //prevent player from shooting List.player.CanShoot = false; DestroyEverything(); }