//Stopping Movement Timers private void MoveTimersStop() { MoveUpTimer.Stop(); MoveDownTimer.Stop(); MoveLeftTimer.Stop(); MoveRightTimer.Stop(); }
//Key Detection private void Form1_KeyDown(object sender, KeyEventArgs e) { if (lost == false) { if (pause == false) { if (e.KeyCode == Keys.W) { MoveUpTimer.Start(); MoveDownTimer.Stop(); MoveLeftTimer.Stop(); MoveRightTimer.Stop(); } if (e.KeyCode == Keys.A) { MoveLeftTimer.Start(); MoveUpTimer.Stop(); MoveDownTimer.Stop(); MoveRightTimer.Stop(); } if (e.KeyCode == Keys.S) { MoveDownTimer.Start(); MoveUpTimer.Stop(); MoveLeftTimer.Stop(); MoveRightTimer.Stop(); } if (e.KeyCode == Keys.D) { MoveRightTimer.Start(); MoveUpTimer.Stop(); MoveDownTimer.Stop(); MoveLeftTimer.Stop(); } } } }