예제 #1
0
파일: Form1.cs 프로젝트: TomPedersen/Snake
        private void UpdateScreen(object sender, EventArgs e)
        {
            //Check for Game Over
            if (GameSettings.GameOver)
            {
                //Check if Enter key is pressed
                if (ControlsInput.KeyPressed(Keys.Enter))
                {
                    StartGame();
                }
            }
            else
            {
                if (ControlsInput.KeyPressed(Keys.Right) && GameSettings.direction != Direction.Left)
                {
                    GameSettings.direction = Direction.Right;
                }
                else if (ControlsInput.KeyPressed(Keys.Left) && GameSettings.direction != Direction.Right)
                {
                    GameSettings.direction = Direction.Left;
                }
                else if (ControlsInput.KeyPressed(Keys.Up) && GameSettings.direction != Direction.Down)
                {
                    GameSettings.direction = Direction.Up;
                }
                else if (ControlsInput.KeyPressed(Keys.Down) && GameSettings.direction != Direction.Up)
                {
                    GameSettings.direction = Direction.Down;
                }

                MovePlayer();
            }

            GameWorld.Invalidate();
        }
예제 #2
0
파일: Form1.cs 프로젝트: TomPedersen/Snake
 private void Form1_KeyUp(object sender, KeyEventArgs e)
 {
     ControlsInput.ChangeState(e.KeyCode, false);
 }