Skip to content

Commit

Permalink
Fix jump control handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Helco committed Mar 21, 2024
1 parent be4a7a4 commit d270881
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion zzre.core/imgui/WindowContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ public void BeginEventUpdate(GameTime time)

private bool HandleEvent(SdlWindow window, Event ev)
{
if ((EventType)ev.Type is EventType.Keydown or EventType.Keyup && (KeyCode)ev.Key.Keysym.Sym is not KeyCode.KPrintscreen)
if ((EventType)ev.Type is EventType.Keydown or EventType.Keyup &&
(KeyCode)ev.Key.Keysym.Sym is not KeyCode.KPrintscreen &&
ev.Key.Repeat == 0)
{
FocusedWindow?.HandleKeyEvent((KeyCode)ev.Key.Keysym.Sym, (EventType)ev.Type is EventType.Keydown);
return FocusedWindow != null;
Expand Down
1 change: 0 additions & 1 deletion zzre/game/systems/player/FairyPhysics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ private void ApplyJumps(
velocityComp.Value.Y < MaxJumpVelocity)
{
velocityComp.Value += Vector3.UnitY * JumpVelocity;
controls.Jumps = false; // TODO: CHECK THIS, this is not original
}
}

Expand Down
17 changes: 14 additions & 3 deletions zzre/game/systems/player/PlayerControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ protected override void Update(float elapsedTime, ref components.PlayerControls
component.GoesBackward = nextControls.GoesBackward;
component.GoesRight = nextControls.GoesRight;
component.GoesLeft = nextControls.GoesLeft;
component.SwitchesSpells = nextControls.SwitchesSpells;

if (nextControls.Shoots)
component.FrameCountShooting++;
Expand All @@ -85,10 +84,22 @@ protected override void Update(float elapsedTime, ref components.PlayerControls

// Jump is weird, it is set by the physics system (both true and false)
// so we should override it with care
if (jumpChanged)
if (jumpLockDuration > 0f)
{
if (jumpChanged)
{
component.Jumps = nextControls.Jumps;
jumpChanged = false;
}
}
else
{
// however only in Overworld. In Duels the jumps and spell switches
// are only active for a single frame
component.Jumps = nextControls.Jumps;
jumpChanged = false;
component.SwitchesSpells = nextControls.SwitchesSpells;
nextControls.Jumps = false;
nextControls.SwitchesSpells = false;
}
}

Expand Down

0 comments on commit d270881

Please sign in to comment.