Exemplo n.º 1
0
        public InputManager(GameEngine engine)
        {
            KeyboardState = new Dictionary<Keyboard.Key,bool>();
            PreviousKeyboardState = new Dictionary<Keyboard.Key,bool>();

            MouseState = new Dictionary<Mouse.Button,bool>();
            PreviousMouseState = new Dictionary<Mouse.Button,bool>();

            MousePosition = new Vector2i(0,0);
            PreviousMousePosition = new Vector2i(0,0);

            //game.Window.MouseWheelMoved += Window_MouseWheelMoved;

            foreach (Keyboard.Key key in keysEnum)
            {
                KeyboardState.Add(key,false);
                PreviousKeyboardState.Add(key, false);
            }

            foreach (Mouse.Button mouseButton in buttonsEnum)
            {
                MouseState.Add(mouseButton, false);
                PreviousMouseState.Add(mouseButton, false);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); // for .Parse functions

            using (GameEngine engine = new GameEngine())
            {
                engine.PushState(new JedenGameState());
                engine.Run();
            }
        }
Exemplo n.º 3
0
        public void Update(GameEngine engine)
        {
            //Console.WriteLine(DeltaScrollWheel);
            //DeltaScrollWheel = 0; //we only want the difference for each frame, the total value is irrelevant

            PreviousKeyboardState.Clear();
            PreviousMouseState.Clear();
            PreviousMousePosition = MousePosition;

            MousePosition = Mouse.GetPosition(engine.Window);
            foreach (KeyValuePair<Keyboard.Key,bool> valuePair in KeyboardState)
            {
                PreviousKeyboardState.Add(valuePair.Key, valuePair.Value);
            }
            foreach (KeyValuePair<Mouse.Button, bool> valuePair in MouseState)
            {
                PreviousMouseState.Add(valuePair.Key, valuePair.Value);
            }

            KeyboardState.Clear();
            MouseState.Clear();
            foreach (Keyboard.Key key in keysEnum)
            {
                KeyboardState.Add(key, CheckKey(key));
            }
            foreach (Mouse.Button button in buttonsEnum)
            {
                MouseState.Add(button, CheckButton(button));
            }
        }