コード例 #1
0
 //Stopping Movement Timers
 private void MoveTimersStop()
 {
     MoveUpTimer.Stop();
     MoveDownTimer.Stop();
     MoveLeftTimer.Stop();
     MoveRightTimer.Stop();
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: balee323/TeachingCode
        //KeyUp Event Handler
        private void SpaceForm_KeyUp(object sender, KeyEventArgs e)
        {
            MoveRigthTimer.Stop();
            MoveLeftTimer.Stop();
            MoveDownTimer.Stop();
            MoveTopTimer.Stop();

            if (e.KeyCode == Keys.Space)
            {
                if (!gameIsOver)
                {
                    if (pause)
                    {
                        StartTimers();
                        Text_lbl.Visible = false;
                        GameSong.controls.play();;
                        pause = false;
                    }
                    else
                    {
                        Text_lbl.Location = new Point(20, 150);
                        Text_lbl.Text     = "GAME PAUSED";
                        Text_lbl.Visible  = true;
                        GameSong.controls.pause();
                        StopTimers();
                        pause = true;
                    }
                }
            }
        }
コード例 #3
0
        //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();
                    }
                }
            }
        }