示例#1
0
        private static void GetUserInput()
        {
            if (Mouse.LeftButton == MouseButtonState.Pressed)
            {
                MouseLeftClick();
            }

            if (Keyboard.IsKeyDown(Key.A))
            {
                UserInput.PlayerX = 0 - (Player.Speed * DeltaTime);

                // calculate if collision will occur

                //player.Move(x, player.Y);

                AnimationFrame     = 0;
                AnimationDirection = "Left";

                MainWindow.AnimationTime.IsEnabled = true;
            }
            // else
            //{
            //    MainWindow.AnimationTime.IsEnabled = false;

            //    AnimationFrame = 0;
            //}


            if (Keyboard.IsKeyDown(Key.D))
            {
                //int x = 0 + player.Speed;

                UserInput.PlayerX = 0 + (Player.Speed * DeltaTime);

                // player.Move(x, player.Y);
                AnimationFrame     = 0;
                AnimationDirection = "Right";

                MainWindow.AnimationTime.IsEnabled = true;
            }


            if (Keyboard.IsKeyDown(Key.W))
            {
                //int y = 0 - player.Speed;

                UserInput.PlayerY = 0 - (Player.Speed * DeltaTime);

                //player.Move(player.X, y);

                AnimationFrame     = 0;
                AnimationDirection = "Up";

                MainWindow.AnimationTime.IsEnabled = true;
            }


            if (Keyboard.IsKeyDown(Key.S))
            {
                //int y = 0 + player.Speed;

                UserInput.PlayerY = 0 + (Player.Speed * DeltaTime);

                //player.Move(player.X, y);

                AnimationFrame     = 0;
                AnimationDirection = "Down";

                MainWindow.AnimationTime.IsEnabled = true;
            }



            // @Debug code for testing the movement 'system'
            if (Keyboard.IsKeyDown(Key.F))
            {
                Player.X = 5;
                Player.Y = 5;

                Player.Move(Player.X, Player.Y);
            }
        }
示例#2
0
        private static void UpdateCanvas()
        {
            Player.Move(UserInput.PlayerX, UserInput.PlayerY);

            UserInput.Reset();
        }