//Properties //Interfaces //Methods protected override void OnLoad(EventArgs e) { base.OnLoad(e); GL.ClearColor(Color.Black); GL.Enable(EnableCap.DepthTest); inputState = new InputState(new List<Key>(), new ControlsConfig("CONTROLS")); stateManager.InputState = inputState; //syncs input with state manager //initializes with menu screen stateManager.AddState(menu); }
public virtual void ProcessInput(InputState inputState) { this.inputState = inputState; }
public override void ProcessInput(InputState inputState) { base.ProcessInput(inputState); HandlePlayerInput(); inputBuffer = 30; }
//Methods public virtual void Move(InputState inputState) { List<Key> keysPressed = inputState.KeysPressed; ControlsConfig controls = inputState.Controls; //checks for the most recent movement key in an axis and updates player position if (keysPressed.IndexOf(controls.Up) > keysPressed.IndexOf(controls.Down)) { CenterLocation = Vector2.Add(CenterLocation, new Vector2(0, Speed)); } else if (keysPressed.IndexOf(controls.Down) > keysPressed.IndexOf(controls.Up)) { CenterLocation = Vector2.Add(CenterLocation, new Vector2(0, -Speed)); } if (keysPressed.IndexOf(controls.Left) > keysPressed.IndexOf(controls.Right)) { CenterLocation = Vector2.Add(CenterLocation, new Vector2(-Speed, 0)); } else if (keysPressed.IndexOf(controls.Right) > keysPressed.IndexOf(controls.Left)) { CenterLocation = Vector2.Add(CenterLocation, new Vector2(Speed, 0)); } }