public void OnKeyUp(KeyEventArgs e) { Handler.KeyInPutHandler(this, e.KeyCode, KeyHandlerAction.Up); while (PressedKeys.Contains(e.KeyData)) { PressedKeys.Remove(e.KeyData); } if (e.KeyData != Keys.Space) { return; } Field.AddObject(AddableObjects.Mine, this, MainPlayer.CenterPosition()); var obj = Field.Objects.Last(); obj.Position = obj.Position.Sub(obj.Size.Div(2)); }
public override void Update(GameTime gameTime) { base.Update(gameTime); ReleasedKeys.Clear(); ClickedKeys.Clear(); KeyboardState state = Keyboard.GetState(); foreach (IPressedKey pressedKey in new List <IPressedKey>(PressedKeys)) { bool isPressed = false; foreach (Keys key in state.GetPressedKeys()) { if (key == pressedKey.Key) { isPressed = true; } } if (!isPressed) { PressedKeys.Remove(pressedKey); ReleasedKeys.Add(pressedKey.Key); } } foreach (Keys key in state.GetPressedKeys()) { bool isAlreadyPressed = false; foreach (IPressedKey pressedKey in PressedKeys) { if (key == pressedKey.Key) { isAlreadyPressed = true; } } if (!isAlreadyPressed) { PressedKeys.Add(new PressedKey(key, gameTime.TotalGameTime.TotalSeconds)); ClickedKeys.Add(key); } } }
public override void UpdateInput(bool isActive) { OpenTK.Input.KeyboardState state = OpenTK.Input.Keyboard.GetState(); PressedKeys.Clear(); if (state.IsAnyKeyDown) { foreach (Key k in Enum.GetValues(typeof(Key))) { if (state.IsKeyDown(k)) { PressedKeys.Add(k); } } } }
private static void Postfix(ref ModifierKeys __result) { var modifiers = ModifierKeys.None; if (PressedKeys.Contains(Key.LeftShift) || PressedKeys.Contains(Key.RightShift)) { modifiers |= ModifierKeys.Shift; } if (PressedKeys.Contains(Key.LeftCtrl) || PressedKeys.Contains(Key.RightCtrl)) { modifiers |= ModifierKeys.Control; } if (PressedKeys.Contains(Key.LeftAlt) || PressedKeys.Contains(Key.RightAlt)) { modifiers |= ModifierKeys.Alt; } __result = modifiers; }
protected override void OnToolKeyDown(MapViewKeyEventArgs k) { _msg.VerboseDebug("OnToolKeyDown"); try { PressedKeys.Add(k.Key); if (IsModifierKey(k.Key) || HandledKeys.Contains(k.Key)) { k.Handled = true; } if (k.Key == _keyShowOptionsPane) { ShowOptionsPane(); } // Cancel outside a queued task otherwise the current task that blocks the queue // cannot be cancelled. if (k.Key == Key.Escape) { HandleEscape(); } QueuedTaskUtils.Run( delegate { if (IsShiftKey(k.Key) && SelectionCursorShift != null && IsInSelectionPhase()) { SetCursor(SelectionCursorShift); } OnKeyDownCore(k); return(true); }); } catch (Exception e) { HandleError($"Error in tool key down ({Caption}): {e.Message}", e, true); } }
public virtual void Update() { PressedKeys.Clear(); ReleasedKeys.Clear(); foreach (KeyEventArgs keyEvent in keyEvents) { if (DownKeys.Contains(keyEvent.Key)) { PressedKeys.Add(keyEvent.Key); } else { ReleasedKeys.Add(keyEvent.Key); } } keyEvents.Clear(); }
public void OnKeyPressed(object sender, GlobalKeyboardHookEventArgs e) { // https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx if (!CheckFocusedWindow()) { return; } int vk = e.KeyboardData.VirtualCode; Keys key = (Keys)vk; // Key down if (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown) { if (!PressedKeys.ContainsKey(key)) { PressedKeys.Add(key, true); ExecuteActionsByKey(PressedKeys.Keys.ToList()); } e.Handled = true; } // Key up else if (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyUp) { if (PressedKeys.ContainsKey(key)) { PressedKeys.Remove(key); ExecuteActionsByKey(PressedKeys.Keys.ToList()); } e.Handled = true; } // Reset state if (!IsKeyDown()) { CurrentState = null; } }
protected override async Task <bool> OnSketchModifiedAsync() { _msg.VerboseDebug("OnSketchModifiedAsync"); if (_updateFeedbackTask != null) { // Still working on the previous update (large poylgons!) // -> Consider using latch (but ensure that the overlay must probably be scheduled properly) return(false); } bool nonDefaultSide = _nonDefaultSideMode || PressedKeys.Contains(_keyToggleNonDefaultSide); bool updated = false; try { if (!PressedKeys.Contains(Key.Space)) { // TODO: Exclude finish sketch by double clicking -> should not calculate preview // E.g. wait for SystemInformation.DoubleClickTime for the second click // and only start if it has not ocvurred _updateFeedbackTask = UpdateFeedbackAsync(nonDefaultSide); updated = await _updateFeedbackTask; } } catch (Exception e) { _msg.Warn("Error generating preview", e); return(false); } finally { _updateFeedbackTask = null; } // Does it make any difference what the return value is? return(updated); }
/// <summary> /// Updates the input system. Should be called once per frame. /// </summary> /// <param name="deltaTime">Time in seconds which has passed since the last frame.</param> public static void Update(float deltaTime) { // TODO: Multiple gamepad support (local multiplayer). // Check for capabilities each second. Reduces GC allocations. if (curCapabilityTimer >= _CAPABILITY_CHECK_TIMER) { for (int i = 0; i < GamePadCapabilities.Length; i++) { GamePadCapabilities[i] = GamePad.GetCapabilities(i); } curCapabilityTimer = 0.0f; } else { curCapabilityTimer += deltaTime; } for (int i = 0; i < GamePadCapabilities.Length; i++) { GamePadStates[i] = GamePadCapabilities[i].IsConnected ? GamePad.GetState(i) : default; } // Clear pressed keys. PressedKeys.Clear(); PressedChars.Clear(); // Update inputs. if (IsActive) { UpdateInputs(deltaTime); } // Clean-up for next frame. oldScrollValue = scrollValue; oldPressedChars.Clear(); }
private static void Postfix(Key key, ref bool __result) { __result = !PressedKeys.Contains(key); }
public void Update(Map map, ParticleManager pMan, Character[] c) { if (Ai != null) Ai.Update(c, ID, map); PressedKey = PressedKeys.None; if (KeyAttack) { PressedKey = PressedKeys.Attack; if (KeyUp) PressedKey = PressedKeys.Lower; if (KeyDown) PressedKey = PressedKeys.Upper; } if (KeySecondary) { PressedKey = PressedKeys.Secondary; if (KeyUp) PressedKey = PressedKeys.SecUp; if (KeyDown) PressedKey = PressedKeys.SecDown; } if (PressedKey > PressedKeys.None) { if (GotoGoal[(int)PressedKey] > -1) { SetFrame(GotoGoal[(int)PressedKey]); if (KeyLeft) Face = CharDir.Left; if (KeyRight) Face = CharDir.Right; PressedKey = PressedKeys.None; for (int i = 0; i < GotoGoal.Length; i++) GotoGoal[i] = -1; frame = 0f; } } if (StunFrame > 0f) StunFrame -= Game1.FrameTime; #region Update Dying if (DyingFrame > -1f) { DyingFrame += Game1.FrameTime; } #endregion #region Update Animation if (DyingFrame < 0f) { Animation animation = charDef.GetAnimation(Anim); KeyFrame keyframe = animation.GetKeyFrame(AnimFrame); frame += Game1.FrameTime * 30.0f; if (frame > (float)keyframe.Duration) { int pframe = AnimFrame; script.DoScript(Anim, AnimFrame); CheckTrig(pMan); frame -= (float)keyframe.Duration; if (AnimFrame == pframe) AnimFrame++; keyframe = animation.GetKeyFrame(AnimFrame); if (AnimFrame >= animation.getKeyFrameArray().Length) AnimFrame = 0; } if (keyframe.FrameRef < 0) AnimFrame = 0; if (AnimName == "jhit") { if (Trajectory.Y > -100f) SetAnim("jmid"); } } #endregion #region Collison w/ other characters for (int i = 0; i < c.Length; i++) { if (i != ID) { if (c[i] != null) { if (!ethereal && !c[i].ethereal) { if (Loc.X > c[i].Loc.X - 90f * c[i].Scale && Loc.X < c[i].Loc.X + 90f * c[i].Scale && Loc.Y > c[i].Loc.Y - 120f * c[i].Scale && Loc.Y < c[i].Loc.Y + 10f * c[i].Scale) { float dif = (float)Math.Abs(Loc.X - c[i].Loc.X); dif = 180f * c[i].Scale - dif; dif *= 2f; if (Loc.X < c[i].Loc.X) { ColMove = -dif; c[i].ColMove = dif; } else { ColMove = dif; c[i].ColMove = -dif; } } } } } } if (ColMove > 0f) { ColMove -= 400f * Game1.FrameTime; if (ColMove < 0f) ColMove = 0f; } if (ColMove < 0f) { ColMove += 400f * Game1.FrameTime; if (ColMove > 0f) ColMove = 0f; } #endregion #region Update loc by trajectory Vector2 pLoc = new Vector2(Loc.X, Loc.Y); if (State == CharState.Grounded || (State == CharState.Air && Floating)) { if (Trajectory.X > 0f) { Trajectory.X -= Game1.Friction * Game1.FrameTime; if (Trajectory.X < 0f) Trajectory.X = 0f; } if (Trajectory.X < 0f) { Trajectory.X += Game1.Friction * Game1.FrameTime; if (Trajectory.X > 0f) Trajectory.X = 0f; } } Loc.X += Trajectory.X * Game1.FrameTime; Loc.X += ColMove * Game1.FrameTime; if (State == CharState.Air) { Loc.Y += Trajectory.Y * Game1.FrameTime; } #endregion #region Collision detection if (State == CharState.Air) { #region Air State if (Floating) { Trajectory.Y += Game1.FrameTime * Game1.Gravity * 0.5f; if (Trajectory.Y > 100f) Trajectory.Y = 100f; if (Trajectory.Y < -100f) Trajectory.Y = -100f; } else Trajectory.Y += Game1.FrameTime * Game1.Gravity; CheckXCol(map, pLoc); #region Land on ledge if (Trajectory.Y > 0.0f) { for (int i = 0; i < 16; i++) { if (map.GetLedgeTotalNodes(i) > 1) { int ts = map.GetLedgeSec(i, pLoc.X); int s = map.GetLedgeSec(i, Loc.X); float fY; float tfY; if (s > -1 && ts > -1) { tfY = map.GetLedgeYLoc(i, s, pLoc.X); fY = map.GetLedgeYLoc(i, s, Loc.X); if (pLoc.Y <= tfY && Loc.Y >= fY) { if (Trajectory.Y > 0.0f) { Loc.Y = fY; ledgeAttach = i; Land(); } } else if (map.GetLedgeFlags(i) == (int)LedgeFlags.Solid && Loc.Y >= fY) { Loc.Y = fY; ledgeAttach = i; Land(); } } } } } #endregion #region Land on col if (State == CharState.Air) { if (Trajectory.Y > 0f) { if (map.CheckCol(new Vector2(Loc.X, Loc.Y + 15f))) { Loc.Y = (float)((int)((Loc.Y + 15f) / 64f) * 64); Land(); } } } #endregion #endregion } else if (State == CharState.Grounded) { #region Grounded State if (ledgeAttach > -1) { if (map.GetLedgeSec(ledgeAttach, Loc.X) == -1) { FallOff(); } else { Loc.Y = map.GetLedgeYLoc(ledgeAttach, map.GetLedgeSec(ledgeAttach, Loc.X), Loc.X); } } else { if (!map.CheckCol(new Vector2(Loc.X, Loc.Y + 15f))) FallOff(); } CheckXCol(map, pLoc); #endregion } #endregion #region Key input if (AnimName == "idle" || AnimName == "run" || (State == CharState.Grounded && CanCancel)) { if (AnimName == "idle" || AnimName == "run") { if (KeyLeft) { SetAnim("run"); Trajectory.X = -Speed; Face = CharDir.Left; } else if (KeyRight) { SetAnim("run"); Trajectory.X = Speed; Face = CharDir.Right; } else { SetAnim("idle"); } } if (KeyAttack) { SetAnim("attack"); } if (KeySecondary) { SetAnim("second"); } if (KeyJump) { SetAnim("jump"); } if (RightAnalog.X > 0.2f || RightAnalog.X < -0.2f) { SetAnim("roll"); if (AnimName == "roll") { if (RightAnalog.X > 0f) Face = CharDir.Right; else Face = CharDir.Left; } } } if (AnimName == "fly" || (State == CharState.Air && CanCancel)) { if (KeyLeft) { Face = CharDir.Left; if (Trajectory.X > -Speed) Trajectory.X -= 500f * Game1.FrameTime; } if (KeyRight) { Face = CharDir.Right; if (Trajectory.X < Speed) Trajectory.X += 500f * Game1.FrameTime; } if (KeySecondary) { SetAnim("fsecond"); } if (KeyAttack) { SetAnim("fattack"); } } #endregion }
private static void SetKey(PressedKeys key) { lock (_keysLocker) { _keys ^= key; } }
public bool IsKeyDown(Key key) { return(PressedKeys.Contains(key)); }
internal void OnKeyDown(object sender, KeyEventArgs e) { PressedKeys.Add(e.KeyCode); HeldKeys.Add(e.KeyCode); }
/// <summary> /// Check if a key got pressed or released. Triggered on the falling and rising edge of a keystroke. /// </summary> public bool CheckEdge(Keys key) { return(PressedKeys.Contains(key) ^ LastPressedKeys.Contains(key)); }
/// <summary> /// Check if a key got released. Triggered once per keystroke /// </summary> /// <param name="key"></param> /// <returns></returns> public bool CheckReleased(Keys key) { return(!PressedKeys.Contains(key) && LastPressedKeys.Contains(key)); }
/// <summary> /// Returns true on the frame that the key was pressed. Triggered once per keystroke /// </summary> public bool CheckPressed(Keys key) { return(PressedKeys.Contains(key) && !LastPressedKeys.Contains(key)); }
/// <summary> /// Checks if a key is pressed /// </summary> public bool Check(Keys key) { return(PressedKeys.Contains(key)); }
public void RemovePressedKeyByIndex(int index) { PressedKeys.RemoveAt(index); }
private void onDeactivate(object sender, EventArgs e) { PressedKeys.Clear(); }
internal void Update() { PressedKeys.Clear(); ReleasedKeys.Clear(); }
/// <summary> /// Has to be called every Update to ensure correct calling /// </summary> public void Update(GameTime gameTime) { // Shift pressed to lastPressed LastPressedKeys = new List <Keys>(PressedKeys); PressedKeys.Clear(); KeyboardState state = Keyboard.GetState(); PressedKeys.AddRange(state.GetPressedKeys()); // Add simulated keys foreach (Keys key in SimulatedKeys) { if (!PressedKeys.Contains(key)) { PressedKeys.Add(key); } } // Get pressed time for gmkeyboard.string // Remove released keys foreach (Keys key in PressTime.Keys.ToList()) { if (!PressedKeys.Contains(key)) { PressTime.Remove(key); } } // Add newly pressed keys to pressTime foreach (Keys key in PressedKeys) { if (!PressTime.ContainsKey(key)) { PressTime.Add(key, -gameTime.ElapsedGameTime.TotalMilliseconds); } } Dictionary <Keys, double> lastPressTime = new Dictionary <Keys, double>(PressTime); TriggeredKeys.Clear(); // Handle KeyboardString foreach (Keys key in PressTime.Keys.ToList()) { // Don't add key to string if it isn't allowed to if (Settings.AddSimulatedKeysToKeyboardString == false) { if (SimulatedKeys.Contains(key)) { break; } } PressTime[key] += gameTime.ElapsedGameTime.TotalMilliseconds; bool shouldFire = false; // Fire if key is just pressed if (PressTime[key] == 0) { shouldFire = true; } // Check if it should refire because key is hold if (PressTime[key] >= Settings.ReFireDelay) { int maxTime = Settings.ReFireDelay + Settings.ReFireInterval * 20; if (PressTime[key] > maxTime) { PressTime[key] -= Settings.ReFireInterval * 20; lastPressTime[key] -= Settings.ReFireInterval * 20; } for (int t = Settings.ReFireDelay; t < maxTime; t += Settings.ReFireInterval) { if (PressTime[key] > t && lastPressTime[key] < t) { shouldFire = true; } } } if (shouldFire) { TriggeredKeys.Add(key); // s = shift pressed? bool s = Check(Keys.LeftShift) | Check(Keys.RightShift); string keyString = key.ToString(); if (Alphabet.Contains(key)) { s = state.CapsLock ? !s : s; // Invert shift if CapsLock is on String += s ? keyString : keyString.ToLower(); } else { bool nl = state.NumLock; switch (key) { case Keys.Space: String += " "; break; case Keys.Back: if (String.Length > 0) { String = String.Substring(0, String.Length - 1); } break; case Keys.D1: String += s ? "!" : "1"; break; case Keys.D2: String += s ? "@" : "2"; break; case Keys.D3: String += s ? "#" : "3"; break; case Keys.D4: String += s ? "$" : "4"; break; case Keys.D5: String += s ? "%" : "5"; break; case Keys.D6: String += s ? "^" : "6"; break; case Keys.D7: String += s ? "&" : "7"; break; case Keys.D8: String += s ? "*" : "8"; break; case Keys.D9: String += s ? "(" : "9"; break; case Keys.D0: String += s ? ")" : "0"; break; case Keys.OemComma: String += s ? "<" : ","; break; case Keys.OemPeriod: String += s ? ">" : "."; break; case Keys.OemQuestion: String += s ? "?" : "/"; break; case Keys.OemSemicolon: String += s ? ":" : ";"; break; case Keys.OemQuotes: String += s ? "\"" : "'"; break; case Keys.OemPipe: String += s ? "|" : "\\"; break; case Keys.OemMinus: String += s ? "_" : "-"; break; case Keys.OemPlus: String += s ? "+" : "="; break; case Keys.OemOpenBrackets: String += s ? "{" : "["; break; case Keys.OemCloseBrackets: String += s ? "}" : "]"; break; case Keys.OemTilde: String += s ? "~" : "`"; break; case Keys.NumPad0: String += nl ? "0" : ""; break; case Keys.NumPad1: String += nl ? "1" : ""; break; case Keys.NumPad2: String += nl ? "2" : ""; break; case Keys.NumPad3: String += nl ? "3" : ""; break; case Keys.NumPad4: String += nl ? "4" : ""; break; case Keys.NumPad5: String += nl ? "5" : ""; break; case Keys.NumPad6: String += nl ? "6" : ""; break; case Keys.NumPad7: String += nl ? "7" : ""; break; case Keys.NumPad8: String += nl ? "8" : ""; break; case Keys.NumPad9: String += nl ? "9" : ""; break; case Keys.Multiply: String += "*"; break; case Keys.Divide: String += "/"; break; case Keys.Add: String += "+"; break; case Keys.Subtract: String += "-"; break; case Keys.Decimal: String += "."; break; case Keys.Enter: String += Settings.ParseEnter ? "\n" : ""; break; case Keys.Tab: String += Settings.ParseTab ? "\t" : ""; break; default: break; } } // Limit Keyboard.String length if (String.Length > Settings.StoreLength) { String = String.Substring(String.Length - Settings.StoreLength); } } } }
public _Input(PressedKeys keys) { Keys = keys; }
public void Update(ParticleManager pMan, Character[] c) { #region Update AI if (Ai != null) Ai.Update(c, Id, Map); #endregion #region Update Dying if (DyingFrame > -1) DyingFrame += Game1.FrameTime; #endregion #region Update animation if (DyingFrame < 0) { var animation = _charDef.Animations[Anim]; var keyFrame = animation.KeyFrames[AnimFrame]; _frame += Game1.FrameTime * 30; if (_frame > keyFrame.Duration) { var pFrame = AnimFrame; _script.DoScript(Anim, AnimFrame); CheckTrig(pMan); _frame -= keyFrame.Duration; if (AnimFrame == pFrame) AnimFrame++; if (AnimFrame >= animation.KeyFrames.Length) AnimFrame = 0; keyFrame = animation.KeyFrames[AnimFrame]; if (keyFrame.FrameRef < 0) AnimFrame = 0; } } #endregion #region Collison w/ other characters for (var i = 0; i < c.Length; i++) { if (i != Id) { if (c[i] != null) { if (!Ethereal && !c[i].Ethereal) { if (Location.X > c[i].Location.X - 90f * c[i].Scale && Location.X < c[i].Location.X + 90f * c[i].Scale && Location.Y > c[i].Location.Y - 120f * c[i].Scale && Location.Y < c[i].Location.Y + 10f * c[i].Scale) { var dif = Math.Abs(Location.X - c[i].Location.X); dif = 180f * c[i].Scale - dif; dif *= 2f; if (Location.X < c[i].Location.X) { ColMove = -dif; c[i].ColMove = dif; } else { ColMove = dif; c[i].ColMove = -dif; } } } } } } if (ColMove > 0f) { ColMove -= 400f * Game1.FrameTime; if (ColMove < 0f) ColMove = 0f; } else if (ColMove < 0f) { ColMove += 400f * Game1.FrameTime; if (ColMove > 0f) ColMove = 0f; } #endregion #region Update location by trajectory var pLoc = Location; if (State == CharState.Grounded) { if (Trajectory.X > 0) { Trajectory.X -= Game1.Friction * Game1.FrameTime; if (Trajectory.X < 0) Trajectory.X = 0; } if (Trajectory.X < 0) { Trajectory.X += Game1.Friction * Game1.FrameTime; if (Trajectory.X > 0) Trajectory.X = 0; } } Location.X += Trajectory.X * Game1.FrameTime; Location.X += ColMove * Game1.FrameTime; if (State == CharState.Air) { Location.Y += Trajectory.Y * Game1.FrameTime; Trajectory.Y += Game1.FrameTime * Game1.Gravity; } #endregion #region Colision detection if (State == CharState.Air) { CheckXCol(pLoc); #region Land on ledge if (Trajectory.Y > 0) { for (var i = 0; i < 16; i++) { if (Map.Ledges[i].TotalNodes > 1) { var ts = Map.GetLedgeSec(i, pLoc.X); var s = Map.GetLedgeSec(i, Location.X); if (s > -1 && ts > -1) { var tfy = Map.GetLedgeYLoc(i, s, pLoc.X); var fy = Map.GetLedgeYLoc(i, s, Location.X); if (pLoc.Y <= tfy && Location.Y >= fy) { if (Trajectory.Y > 0) { Location.Y = fy; _ledgeAttach = i; Land(); } } else { if (Map.Ledges[i].Flags == (int)LedgeFlags.Solid && Location.Y >= fy) { Location.Y = fy; _ledgeAttach = i; Land(); } } } } } } #endregion #region Land on col if (State == CharState.Air && Trajectory.Y > 0) { if (Map.CheckCol(new Vector2(Location.X, Location.Y + 15))) { Location.Y = (int)(Location.Y + 15) / 64 * 64; Land(); } } #endregion } else if (State == CharState.Grounded) { #region Grounded state if (_ledgeAttach > -1) { if (Map.GetLedgeSec(_ledgeAttach, Location.X) == -1) { FallOff(); } else { Location.Y = Map.GetLedgeYLoc(_ledgeAttach, Map.GetLedgeSec(_ledgeAttach, Location.X), Location.X); } } else { if (!Map.CheckCol(new Vector2(Location.X, Location.Y + 15))) FallOff(); } CheckXCol(pLoc); #endregion } #endregion #region UpdateKey input if (AnimName == "idle" || AnimName == "run") { if (KeyLeft) { SetAnim("run"); Trajectory.X = -200; Face = CharDir.Left; } else if (KeyRight) { SetAnim("run"); Trajectory.X = 200; Face = CharDir.Right; } else { SetAnim("idle"); } if (KeyAttack) { SetAnim("attack"); } if (KeySecondary) { SetAnim("second"); } if (KeyJump) { SetAnim("fly"); Trajectory.Y = -600; State = CharState.Air; _ledgeAttach = -1; if (KeyRight) Trajectory.X = 200; else if (KeyLeft) Trajectory.X = -200; } } if (AnimName == "fly") { if (KeyLeft) { Face = CharDir.Left; if (Trajectory.X > -200) Trajectory.X -= 500 * Game1.FrameTime; } else if (KeyRight) { Face = CharDir.Right; if (Trajectory.X < 200) Trajectory.X += 500 * Game1.FrameTime; } } PressedKey = PressedKeys.None; if (KeyAttack) PressedKey = KeyUp ? PressedKeys.Lower : KeyDown ? PressedKeys.Upper : PressedKeys.Attack; if (KeySecondary) PressedKey = KeyUp ? PressedKeys.SecUp : KeyDown ? PressedKeys.SecDown : PressedKeys.Secondary; if (PressedKey != PressedKeys.None) { if (GotoGoal[(int)PressedKey] > -1) { AnimFrame = GotoGoal[(int)PressedKey]; if (KeyLeft) Face = CharDir.Left; else if (KeyRight) Face = CharDir.Right; PressedKey = PressedKeys.None; for (var i = 0; i < GotoGoal.Length; i++) GotoGoal[i] = -1; _frame = 0; _script.DoScript(Anim, AnimFrame); } } #endregion }
public void Update(Map map, ParticleManager pMan, Character[] c) { if (Ai != null) { Ai.Update(c, ID, map); } PressedKey = PressedKeys.None; if (KeyAttack) { PressedKey = PressedKeys.Attack; if (KeyUp) { PressedKey = PressedKeys.Lower; } if (KeyDown) { PressedKey = PressedKeys.Upper; } } if (KeySecondary) { PressedKey = PressedKeys.Secondary; if (KeyUp) { PressedKey = PressedKeys.SecUp; } if (KeyDown) { PressedKey = PressedKeys.SecDown; } } if (PressedKey > PressedKeys.None) { if (GotoGoal[(int)PressedKey] > -1) { SetFrame(GotoGoal[(int)PressedKey]); if (KeyLeft) { Face = CharDir.Left; } if (KeyRight) { Face = CharDir.Right; } PressedKey = PressedKeys.None; for (int i = 0; i < GotoGoal.Length; i++) { GotoGoal[i] = -1; } frame = 0f; } } if (StunFrame > 0f) { StunFrame -= Game1.FrameTime; } #region Update Dying if (DyingFrame > -1f) { DyingFrame += Game1.FrameTime; } #endregion #region Update Animation if (DyingFrame < 0f) { Animation animation = charDef.GetAnimation(Anim); KeyFrame keyframe = animation.GetKeyFrame(AnimFrame); frame += Game1.FrameTime * 30.0f; if (frame > (float)keyframe.Duration) { int pframe = AnimFrame; script.DoScript(Anim, AnimFrame); CheckTrig(pMan); frame -= (float)keyframe.Duration; if (AnimFrame == pframe) { AnimFrame++; } keyframe = animation.GetKeyFrame(AnimFrame); if (AnimFrame >= animation.getKeyFrameArray().Length) { AnimFrame = 0; } } if (keyframe.FrameRef < 0) { AnimFrame = 0; } if (AnimName == "jhit") { if (Trajectory.Y > -100f) { SetAnim("jmid"); } } } #endregion #region Collison w/ other characters for (int i = 0; i < c.Length; i++) { if (i != ID) { if (c[i] != null) { if (!ethereal && !c[i].ethereal) { if (Loc.X > c[i].Loc.X - 90f * c[i].Scale && Loc.X <c[i].Loc.X + 90f * c[i].Scale && Loc.Y> c[i].Loc.Y - 120f * c[i].Scale && Loc.Y < c[i].Loc.Y + 10f * c[i].Scale) { float dif = (float)Math.Abs(Loc.X - c[i].Loc.X); dif = 180f * c[i].Scale - dif; dif *= 2f; if (Loc.X < c[i].Loc.X) { ColMove = -dif; c[i].ColMove = dif; } else { ColMove = dif; c[i].ColMove = -dif; } } } } } } if (ColMove > 0f) { ColMove -= 400f * Game1.FrameTime; if (ColMove < 0f) { ColMove = 0f; } } if (ColMove < 0f) { ColMove += 400f * Game1.FrameTime; if (ColMove > 0f) { ColMove = 0f; } } #endregion #region Update loc by trajectory Vector2 pLoc = new Vector2(Loc.X, Loc.Y); if (State == CharState.Grounded || (State == CharState.Air && Floating)) { if (Trajectory.X > 0f) { Trajectory.X -= Game1.Friction * Game1.FrameTime; if (Trajectory.X < 0f) { Trajectory.X = 0f; } } if (Trajectory.X < 0f) { Trajectory.X += Game1.Friction * Game1.FrameTime; if (Trajectory.X > 0f) { Trajectory.X = 0f; } } } Loc.X += Trajectory.X * Game1.FrameTime; Loc.X += ColMove * Game1.FrameTime; if (State == CharState.Air) { Loc.Y += Trajectory.Y * Game1.FrameTime; } #endregion #region Collision detection if (State == CharState.Air) { #region Air State if (Floating) { Trajectory.Y += Game1.FrameTime * Game1.Gravity * 0.5f; if (Trajectory.Y > 100f) { Trajectory.Y = 100f; } if (Trajectory.Y < -100f) { Trajectory.Y = -100f; } } else { Trajectory.Y += Game1.FrameTime * Game1.Gravity; } CheckXCol(map, pLoc); #region Land on ledge if (Trajectory.Y > 0.0f) { for (int i = 0; i < 16; i++) { if (map.GetLedgeTotalNodes(i) > 1) { int ts = map.GetLedgeSec(i, pLoc.X); int s = map.GetLedgeSec(i, Loc.X); float fY; float tfY; if (s > -1 && ts > -1) { tfY = map.GetLedgeYLoc(i, s, pLoc.X); fY = map.GetLedgeYLoc(i, s, Loc.X); if (pLoc.Y <= tfY && Loc.Y >= fY) { if (Trajectory.Y > 0.0f) { Loc.Y = fY; ledgeAttach = i; Land(); } } else if (map.GetLedgeFlags(i) == (int)LedgeFlags.Solid && Loc.Y >= fY) { Loc.Y = fY; ledgeAttach = i; Land(); } } } } } #endregion #region Land on col if (State == CharState.Air) { if (Trajectory.Y > 0f) { if (map.CheckCol(new Vector2(Loc.X, Loc.Y + 15f))) { Loc.Y = (float)((int)((Loc.Y + 15f) / 64f) * 64); Land(); } } } #endregion #endregion } else if (State == CharState.Grounded) { #region Grounded State if (ledgeAttach > -1) { if (map.GetLedgeSec(ledgeAttach, Loc.X) == -1) { FallOff(); } else { Loc.Y = map.GetLedgeYLoc(ledgeAttach, map.GetLedgeSec(ledgeAttach, Loc.X), Loc.X); } } else { if (!map.CheckCol(new Vector2(Loc.X, Loc.Y + 15f))) { FallOff(); } } CheckXCol(map, pLoc); #endregion } #endregion #region Key input if (AnimName == "idle" || AnimName == "run" || (State == CharState.Grounded && CanCancel)) { if (AnimName == "idle" || AnimName == "run") { if (KeyLeft) { SetAnim("run"); Trajectory.X = -Speed; Face = CharDir.Left; } else if (KeyRight) { SetAnim("run"); Trajectory.X = Speed; Face = CharDir.Right; } else { SetAnim("idle"); } } if (KeyAttack) { SetAnim("attack"); } if (KeySecondary) { SetAnim("second"); } if (KeyJump) { SetAnim("jump"); } if (RightAnalog.X > 0.2f || RightAnalog.X < -0.2f) { SetAnim("roll"); if (AnimName == "roll") { if (RightAnalog.X > 0f) { Face = CharDir.Right; } else { Face = CharDir.Left; } } } } if (AnimName == "fly" || (State == CharState.Air && CanCancel)) { if (KeyLeft) { Face = CharDir.Left; if (Trajectory.X > -Speed) { Trajectory.X -= 500f * Game1.FrameTime; } } if (KeyRight) { Face = CharDir.Right; if (Trajectory.X < Speed) { Trajectory.X += 500f * Game1.FrameTime; } } if (KeySecondary) { SetAnim("fsecond"); } if (KeyAttack) { SetAnim("fattack"); } } #endregion }
/// <summary> /// Checks if a specific key was pressed this frame. /// </summary> /// <param name="key">Key to check.</param> /// <returns>True if the key was pressed.</returns> public static bool KeyCodePressed(Keys key) => PressedKeys.Contains(key);
public static bool IsKeyPressed(Keys key) { return(PressedKeys.TryGetValue(key, out var pressed) && pressed); }
public static void UpdateState() { keyboardState = Keyboard.GetState(); mouseState = Mouse.GetState(); Keys[] keys = keyboardState.GetPressedKeys(); for (int k = 0; k < pressedKeys.Count; k++) { pressedKeys[k].isActive = false; } for(int i = 0; i < keys.Length; i++) { bool keyFound = false; for(int k = 0; k < pressedKeys.Count; k++) { if(pressedKeys[k].key == keys[i]) { pressedKeys[k].thisFrame = false; pressedKeys[k].isActive = true; keyFound = true; } } if(!keyFound) { PressedKeys newKey = new PressedKeys(); newKey.thisFrame = true; newKey.key = keys[i]; newKey.isActive = true; pressedKeys.Add(newKey); } } pressedKeys.RemoveAll(o => !o.isActive); }
/// <summary> /// Updates the Character, checks for collision and handles input. /// This method has been verified! /// </summary> /// <param name="gameTime">The game time.</param> public void Update(Map map, ParticleManager particleManager, Character[] character) { if (Ai != null) Ai.Update(character, ID, map); PressedKey = PressedKeys.None; if (keyAttack) { PressedKey = PressedKeys.Attack; if (keyUp) PressedKey = PressedKeys.Lower; if (keyDown) PressedKey = PressedKeys.Upper; } if (keySecondary) { PressedKey = PressedKeys.Secondary; if (keyUp) PressedKey = PressedKeys.SecUp; if (keyDown) PressedKey = PressedKeys.SecDown; } if (PressedKey > PressedKeys.None) { if (GotoGoal[(int)PressedKey] > -1) { SetFrame(GotoGoal[(int)PressedKey]); if (keyLeft) Face = CharacterDirection.Left; if (keyRight) Face = CharacterDirection.Right; PressedKey = PressedKeys.None; for (int i = 0; i < GotoGoal.Length; i++) GotoGoal[i] = -1; frame = 0f; } } if (StunFrame > 0f) StunFrame -= RuinExplorersMain.FrameTime; #region update dying if (DyingFrame > -1f) { DyingFrame += RuinExplorersMain.FrameTime; } #endregion #region Update Animation if (DyingFrame < 0) { Animation animation = characterDefinition.Animations[Animation]; KeyFrame keyFrame = animation.KeyFrames[AnimationFrame]; frame += RuinExplorersMain.FrameTime * 30.0f; if (frame > (float)keyFrame.Duration) { int pframe = AnimationFrame; script.DoScript(Animation, AnimationFrame); CheckTrigger(particleManager); frame -= (float)keyFrame.Duration; if (AnimationFrame == pframe) AnimationFrame++; keyFrame = animation.KeyFrames[AnimationFrame]; if (AnimationFrame >= animation.KeyFrames.Length) AnimationFrame = 0; } if (keyFrame.FrameReference < 0) AnimationFrame = 0; if (AnimationName == "jhit") { if (Trajectory.Y > -100f) SetAnim("jmid"); } } #endregion #region Collision with other characters for (int i = 0; i < character.Length; i++) { if (i != ID) { if (character[i] != null) { if (!Ethereal && !character[i].Ethereal) { if (Location.X > character[i].Location.X - 90f * character[i].Scale && Location.X < character[i].Location.X + 90f * character[i].Scale && Location.Y > character[i].Location.Y - 120f * character[i].Scale && Location.Y < character[i].Location.Y + 10f * character[i].Scale) { float dif = (float)Math.Abs(Location.X - character[i].Location.X); dif = 180f * character[i].Scale - dif; dif *= 2f; if (Location.X < character[i].Location.X) { CollisionMove = -dif; character[i].CollisionMove = dif; } else { CollisionMove = dif; character[i].CollisionMove = -dif; } } } } } } if (CollisionMove > 0f) { CollisionMove -= 400f * RuinExplorersMain.FrameTime; if (CollisionMove < 0f) CollisionMove = 0f; } if (CollisionMove < 0f) { CollisionMove += 400f * RuinExplorersMain.FrameTime; if (CollisionMove > 0f) CollisionMove = 0f; } #endregion #region Update Location by Trajectory Vector2 previousLocation = new Vector2(Location.X, Location.Y); if (State == CharacterState.Ground || (State == CharacterState.Air && floating)) { if (Trajectory.X > 0f) { Trajectory.X -= RuinExplorersMain.Friction * RuinExplorersMain.FrameTime; if (Trajectory.X < 0f) Trajectory.X = 0f; } if (Trajectory.X < 0f) { Trajectory.X += RuinExplorersMain.Friction * RuinExplorersMain.FrameTime; if (Trajectory.X > 0f) Trajectory.X = 0f; } } Location.X += Trajectory.X * RuinExplorersMain.FrameTime; Location.X += CollisionMove * RuinExplorersMain.FrameTime; if (State == CharacterState.Air) { Location.Y += Trajectory.Y * RuinExplorersMain.FrameTime; } #endregion #region Collision detection if (State == CharacterState.Air) { #region Air State if (floating) { Trajectory.Y += RuinExplorersMain.FrameTime * RuinExplorersMain.Gravity * 0.5f; if (Trajectory.Y > 100f) Trajectory.Y = 100f; if (Trajectory.Y < -100f) Trajectory.Y = -100f; } else Trajectory.Y += RuinExplorersMain.FrameTime * RuinExplorersMain.Gravity; CheckXCollision(map, previousLocation); #region Land on ledge if (Trajectory.Y > 0.0f) { for (int i = 0; i < 16; i++) { if (map.Legdes[i].TotalNodes > 1) { int ts = map.GetLedgeSection(i, previousLocation.X); int s = map.GetLedgeSection(i, Location.X); float fY; float tfY; if (s > -1 && ts > -1) { tfY = map.GetLedgeYLocation(i, s, previousLocation.X); fY = map.GetLedgeYLocation(i, s, Location.X); if (previousLocation.Y <= tfY && Location.Y >= fY) { if (Trajectory.Y > 0.0f) { Location.Y = fY; ledgeAttach = i; Land(); } } else if (map.Legdes[i].isHardLedge == (int)LedgeFlags.Solid && Location.Y >= fY) { Location.Y = fY; ledgeAttach = i; Land(); } } } } } #endregion #region Land on col if (State == CharacterState.Air) { if (Trajectory.Y > 0f) { if (map.CheckCollision(new Vector2(Location.X, Location.Y + 15f))) { Location.Y = (float)((int)((Location.Y + 15f) / 64f) * 64); Land(); } } } #endregion #endregion } else if (State == CharacterState.Ground) { #region Grounded State if (ledgeAttach > -1) { if (map.GetLedgeSection(ledgeAttach, Location.X) == -1) { FallOff(); } else { Location.Y = map.GetLedgeYLocation(ledgeAttach, map.GetLedgeSection(ledgeAttach, Location.X), Location.X); } } else { if (!map.CheckCollision(new Vector2(Location.X, Location.Y + 15f))) FallOff(); } CheckXCollision(map, previousLocation); #endregion } #endregion #region Key input if (AnimationName == "idle" || AnimationName == "run" || (State == CharacterState.Ground && CanCancel)) { if (AnimationName == "idle" || AnimationName == "run") { if (keyLeft) { SetAnim("run"); Trajectory.X = -Speed; Face = CharacterDirection.Left; } else if (keyRight) { SetAnim("run"); Trajectory.X = Speed; Face = CharacterDirection.Right; } else { SetAnim("idle"); } } if (keyAttack) { SetAnim("attack"); } if (keySecondary) { SetAnim("second"); } if (keyJump) { SetAnim("jump"); } if (RightAnalog.X > 0.2f || RightAnalog.X < -0.2f) { SetAnim("roll"); if (AnimationName == "roll") { if (RightAnalog.X > 0f) Face = CharacterDirection.Right; else Face = CharacterDirection.Left; } } } if (AnimationName == "fly" || (State == CharacterState.Air && CanCancel)) { if (keyLeft) { Face = CharacterDirection.Left; if (Trajectory.X > -Speed) Trajectory.X -= 500f * RuinExplorersMain.FrameTime; } if (keyRight) { Face = CharacterDirection.Right; if (Trajectory.X < Speed) Trajectory.X += 500f * RuinExplorersMain.FrameTime; } if (keySecondary) { SetAnim("fsecond"); } if (keyAttack) { SetAnim("fattack"); } } #endregion }
public void Stop() { PressedKeys.Clear(); ReleasedKeys.Clear(); ClickedKeys.Clear(); }
private void ScreenClicked(MouseEventArgs e, bool isMouseDown) { if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right) { ScreenClicked(new Rectangle( renderPanel.ClientRectangle.X, renderPanel.ClientRectangle.Y, renderPanel.ClientRectangle.Width, renderPanel.ClientRectangle.Height), e.X, e.Y, isMouseDown, e.Button == MouseButtons.Left, PressedKeys.Contains(Keys.ShiftKey) && e.Button == MouseButtons.Right); } }
public void Update(ParticleManager pMan, Character[] c) { #region Update AI if (Ai != null) { Ai.Update(c, Id, Map); } #endregion #region Update Dying if (DyingFrame > -1) { DyingFrame += Game1.FrameTime; } #endregion #region Update animation if (DyingFrame < 0) { var animation = _charDef.Animations[Anim]; var keyFrame = animation.KeyFrames[AnimFrame]; _frame += Game1.FrameTime * 30; if (_frame > keyFrame.Duration) { var pFrame = AnimFrame; _script.DoScript(Anim, AnimFrame); CheckTrig(pMan); _frame -= keyFrame.Duration; if (AnimFrame == pFrame) { AnimFrame++; } if (AnimFrame >= animation.KeyFrames.Length) { AnimFrame = 0; } keyFrame = animation.KeyFrames[AnimFrame]; if (keyFrame.FrameRef < 0) { AnimFrame = 0; } } } #endregion #region Collison w/ other characters for (var i = 0; i < c.Length; i++) { if (i != Id) { if (c[i] != null) { if (!Ethereal && !c[i].Ethereal) { if (Location.X > c[i].Location.X - 90f * c[i].Scale && Location.X <c[i].Location.X + 90f * c[i].Scale && Location.Y> c[i].Location.Y - 120f * c[i].Scale && Location.Y < c[i].Location.Y + 10f * c[i].Scale) { var dif = Math.Abs(Location.X - c[i].Location.X); dif = 180f * c[i].Scale - dif; dif *= 2f; if (Location.X < c[i].Location.X) { ColMove = -dif; c[i].ColMove = dif; } else { ColMove = dif; c[i].ColMove = -dif; } } } } } } if (ColMove > 0f) { ColMove -= 400f * Game1.FrameTime; if (ColMove < 0f) { ColMove = 0f; } } else if (ColMove < 0f) { ColMove += 400f * Game1.FrameTime; if (ColMove > 0f) { ColMove = 0f; } } #endregion #region Update location by trajectory var pLoc = Location; if (State == CharState.Grounded) { if (Trajectory.X > 0) { Trajectory.X -= Game1.Friction * Game1.FrameTime; if (Trajectory.X < 0) { Trajectory.X = 0; } } if (Trajectory.X < 0) { Trajectory.X += Game1.Friction * Game1.FrameTime; if (Trajectory.X > 0) { Trajectory.X = 0; } } } Location.X += Trajectory.X * Game1.FrameTime; Location.X += ColMove * Game1.FrameTime; if (State == CharState.Air) { Location.Y += Trajectory.Y * Game1.FrameTime; Trajectory.Y += Game1.FrameTime * Game1.Gravity; } #endregion #region Colision detection if (State == CharState.Air) { CheckXCol(pLoc); #region Land on ledge if (Trajectory.Y > 0) { for (var i = 0; i < 16; i++) { if (Map.Ledges[i].TotalNodes > 1) { var ts = Map.GetLedgeSec(i, pLoc.X); var s = Map.GetLedgeSec(i, Location.X); if (s > -1 && ts > -1) { var tfy = Map.GetLedgeYLoc(i, s, pLoc.X); var fy = Map.GetLedgeYLoc(i, s, Location.X); if (pLoc.Y <= tfy && Location.Y >= fy) { if (Trajectory.Y > 0) { Location.Y = fy; _ledgeAttach = i; Land(); } } else { if (Map.Ledges[i].Flags == (int)LedgeFlags.Solid && Location.Y >= fy) { Location.Y = fy; _ledgeAttach = i; Land(); } } } } } } #endregion #region Land on col if (State == CharState.Air && Trajectory.Y > 0) { if (Map.CheckCol(new Vector2(Location.X, Location.Y + 15))) { Location.Y = (int)(Location.Y + 15) / 64 * 64; Land(); } } #endregion } else if (State == CharState.Grounded) { #region Grounded state if (_ledgeAttach > -1) { if (Map.GetLedgeSec(_ledgeAttach, Location.X) == -1) { FallOff(); } else { Location.Y = Map.GetLedgeYLoc(_ledgeAttach, Map.GetLedgeSec(_ledgeAttach, Location.X), Location.X); } } else { if (!Map.CheckCol(new Vector2(Location.X, Location.Y + 15))) { FallOff(); } } CheckXCol(pLoc); #endregion } #endregion #region UpdateKey input if (AnimName == "idle" || AnimName == "run") { if (KeyLeft) { SetAnim("run"); Trajectory.X = -200; Face = CharDir.Left; } else if (KeyRight) { SetAnim("run"); Trajectory.X = 200; Face = CharDir.Right; } else { SetAnim("idle"); } if (KeyAttack) { SetAnim("attack"); } if (KeySecondary) { SetAnim("second"); } if (KeyJump) { SetAnim("fly"); Trajectory.Y = -600; State = CharState.Air; _ledgeAttach = -1; if (KeyRight) { Trajectory.X = 200; } else if (KeyLeft) { Trajectory.X = -200; } } } if (AnimName == "fly") { if (KeyLeft) { Face = CharDir.Left; if (Trajectory.X > -200) { Trajectory.X -= 500 * Game1.FrameTime; } } else if (KeyRight) { Face = CharDir.Right; if (Trajectory.X < 200) { Trajectory.X += 500 * Game1.FrameTime; } } } PressedKey = PressedKeys.None; if (KeyAttack) { PressedKey = KeyUp ? PressedKeys.Lower : KeyDown ? PressedKeys.Upper : PressedKeys.Attack; } if (KeySecondary) { PressedKey = KeyUp ? PressedKeys.SecUp : KeyDown ? PressedKeys.SecDown : PressedKeys.Secondary; } if (PressedKey != PressedKeys.None) { if (GotoGoal[(int)PressedKey] > -1) { AnimFrame = GotoGoal[(int)PressedKey]; if (KeyLeft) { Face = CharDir.Left; } else if (KeyRight) { Face = CharDir.Right; } PressedKey = PressedKeys.None; for (var i = 0; i < GotoGoal.Length; i++) { GotoGoal[i] = -1; } _frame = 0; _script.DoScript(Anim, AnimFrame); } } #endregion }
public static bool IsKeyDown(ConsoleKey key) { return(PressedKeys.Any(info => info.Key == key)); }
public override void GameLogic() { // This runs every frame and handles game logic Player player = (Player)GetObjectByName("Player"); SpriteComponent playerSpriteComp = (SpriteComponent)player.GetComponent("SpriteComponent"); GameObject GameResTextObj = GetUIObjectByName("GameRenderTextObj"); TextComponent GameResTextObjComp = (TextComponent)GameResTextObj.GetComponent("TextComponent"); GameResTextObjComp.SetText("Render Width: " + GameResolutionWidth.ToString() + ", Render Height: " + GameResolutionHeight.ToString()); GameObject WindowSizeTextObj = GetUIObjectByName("WindowSizeTextObj"); TextComponent WindowSizeTextObjComp = (TextComponent)WindowSizeTextObj.GetComponent("TextComponent"); WindowSizeTextObjComp.SetText("Window Width: " + WindowWidth.ToString() + ", Render Height: " + WindowHeight.ToString()); // Handle Key Presses if (PressedKeys.Count > 0) { for (int i = 0; i < PressedKeys.Count; i++) { //Keys currentKeyCode = PressedKeys[i]; //printText(EngineClass.debugType.Debug, PressedKeys[i].ToString()); if (PressedKeys[i] == Keys.W) { player.moveUp(60); //playerSpriteComp.SetImageRotation(Rotation.Up); } // REMOVED S to go down because gravity pulls the player down //else if (PressedKeys[i] == Keys.S || PressedKeys[i] == Keys.Down) //{ // player.moveDown(playerSpeed); // //playerSpriteComp.SetImageRotation(Rotation.Down); //} if (PressedKeys[i] == Keys.A) { player.moveLeft(playerSpeed); playerSpriteComp.SetImageRotation(HRotation.Left, VRotation.Up); } else if (PressedKeys[i] == Keys.D) { player.moveRight(playerSpeed); playerSpriteComp.SetImageRotation(HRotation.Right, VRotation.Up); } if (PressedKeys[i] == Keys.Up) { GlobalCoords[1] += 10; } if (PressedKeys[i] == Keys.Down) { GlobalCoords[1] -= 10; } if (PressedKeys[i] == Keys.Left) { GlobalCoords[0] += 10; } if (PressedKeys[i] == Keys.Right) { GlobalCoords[0] -= 10; } if (PressedKeys[i] == Keys.O) { GlobalScale[0] += (float)0.25; GlobalScale[1] += (float)0.25; //PrintText(debugType.Error, "GlobalScale X = " + GlobalScale[0].ToString() + ", Y = " + GlobalScale[1].ToString()); } else if (PressedKeys[i] == Keys.P) { GlobalScale[0] -= (float)0.25; GlobalScale[1] -= (float)0.25; //PrintText(debugType.Error, "GlobalScale X = " + GlobalScale[0].ToString() + ", Y = " + GlobalScale[1].ToString()); } //printText(debugType.Debug, player.x.ToString()); //printText(debugType.Debug, player.y.ToString()); } PressedKeys.Clear(); // Handle Collision //if (player.GetX() + player.GetWidth() > GetCanvasWidth()) //{ // player.x = GetCanvasWidth() - player.width; //} //else if (player.x < 0) //{ // player.x = 0; //} //if (player.y + player.height > GetCanvasHeight()) //{ // player.y = GetCanvasHeight() - player.height; //} //else if (player.y < 0) //{ // player.y = 0; //} } }