Private
Public Access
1
0

fix game
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m20s

This commit is contained in:
Sebastian Unterschütz
2026-03-21 13:31:34 +01:00
parent 78742fc1c4
commit f48ade50bb
6 changed files with 130 additions and 83 deletions

View File

@@ -276,16 +276,49 @@ func (r *Room) HandleInput(input game.ClientInput) {
}
switch input.Type {
case "STATE":
// Vollständigen Input-State atomisch setzen verhindert stuck-Inputs durch
// Paketverlust oder Reihenfolge-Probleme bei Event-basierten Nachrichten.
// Out-of-Order-Schutz: nur neuere States übernehmen
if input.Sequence <= p.LastInputSeq {
return
}
// Richtung: JoyX hat Vorrang vor digitalen Tasten
if input.InputJoyX != 0 {
p.InputX = input.InputJoyX
} else if input.InputLeft && !input.InputRight {
p.InputX = -1
} else if input.InputRight && !input.InputLeft {
p.InputX = 1
} else {
p.InputX = 0
}
// Jump/Down: einmal setzen, nie löschen (Physics-Tick macht das)
if input.InputJump {
p.InputJump = true
// Double Jump spezial-Logik (außerhalb der Physik-Engine)
if !p.OnGround && p.HasDoubleJump && !p.DoubleJumpUsed {
p.VY = -config.JumpVelocity
p.DoubleJumpUsed = true
log.Printf("⚡ %s verwendet Double Jump!", p.Name)
}
}
if input.InputDown {
p.InputDown = true
}
// Legacy-Events (Rückwärtskompatibilität, werden vom neuen Client nicht mehr gesendet)
case "JUMP":
p.InputJump = true // Setze Jump-Flag für Physik-Engine
// Double Jump spezial-Logik (außerhalb der Physik-Engine)
p.InputJump = true
if !p.OnGround && p.HasDoubleJump && !p.DoubleJumpUsed {
p.VY = -config.JumpVelocity
p.DoubleJumpUsed = true
log.Printf("⚡ %s verwendet Double Jump!", p.Name)
}
case "DOWN":
p.InputDown = true // Setze Down-Flag für Fast Fall
p.InputDown = true
case "LEFT_DOWN":
p.InputX = -1
case "LEFT_UP":
@@ -298,6 +331,7 @@ func (r *Room) HandleInput(input game.ClientInput) {
if p.InputX == 1 {
p.InputX = 0
}
case "START":
if input.PlayerID == r.HostID && r.Status == "LOBBY" {
r.StartCountdown()