Private
Public Access
1
0

fix Sync
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 1m34s

This commit is contained in:
Sebastian Unterschütz
2025-11-30 18:49:00 +01:00
parent a05e79f0d1
commit 61e82e0dba

View File

@@ -89,55 +89,89 @@ func simulateChunk(sessionID string, inputs []Input, totalTicks int, vals map[st
// ============================================================================ // ============================================================================
func updatePhysics(s *SimState, didJump, isCrouching bool, currentSpeed float64) { func updatePhysics(s *SimState, didJump, isCrouching bool, currentSpeed float64) {
// 1. Powerup Logik (Jump Boots)
jumpPower := JumpPower jumpPower := JumpPower
if s.BootTicks > 0 { if s.BootTicks > 0 {
jumpPower = HighJumpPower jumpPower = HighJumpPower
s.BootTicks-- s.BootTicks--
} }
// 2. Sind wir am Boden?
isGrounded := checkGrounded(s) isGrounded := checkGrounded(s)
// Fehler behoben: "currentHeight declared but not used" entfernt. // 3. Ducken / Fast Fall
// Wir brauchen es hier nicht, da checkPlatformLanding mit fixen 50.0 rechnet. // (Variable 'currentHeight' entfernt, da sie hier nicht gebraucht wird)
// Die Hitbox-Änderung passiert nur in checkCollisions. if isCrouching {
// Wenn man in der Luft duckt, fällt man schneller ("Fast Fall")
if isCrouching && !isGrounded { if !isGrounded {
s.VelY += 2.0 // Fast Fall s.VelY += 2.0
}
} }
// 4. Springen
if didJump && isGrounded && !isCrouching { if didJump && isGrounded && !isCrouching {
s.VelY = jumpPower s.VelY = jumpPower
isGrounded = false isGrounded = false
checkJumpSuspicion(s)
} }
// 5. Schwerkraft anwenden
s.VelY += Gravity s.VelY += Gravity
oldY := s.PosY oldY := s.PosY
newY := s.PosY + s.VelY newY := s.PosY + s.VelY
landed := false landed := false
// A. Plattform Landung (One-Way Logic) // ============================================================
if s.VelY > 0 { // PLATTFORM KOLLISION (MIT VERTICAL SWEEP)
// ============================================================
if s.VelY > 0 { // Nur wenn wir fallen
// Wir nutzen hier die Standard-Höhe für die Füße.
// Auch beim Ducken bleiben die Füße meist unten (oder ziehen hoch?),
// aber für die Landung auf Plattformen ist die Standard-Box sicherer.
playerFeetOld := oldY + PlayerHeight
playerFeetNew := newY + PlayerHeight
// Player X ist fest bei 50, Breite 30
pLeft := 50.0
pRight := 50.0 + 30.0
for _, p := range s.Platforms { for _, p := range s.Platforms {
hit, landY := checkPlatformLanding(p.X, p.Y, p.Width, 50.0, oldY, newY, s.VelY)
if hit { // 1. Horizontal Check (Großzügig!)
newY = landY // Toleranz an den Rändern (-5 / +5), damit man nicht abrutscht
if (pRight-5.0 > p.X) && (pLeft+5.0 < p.X+p.Width) {
// 2. Vertikaler Sweep (Durchsprung-Schutz)
// Check: Füße waren vorher <= Plattform-Oberkante
// UND Füße sind jetzt >= Plattform-Oberkante
if playerFeetOld <= p.Y && playerFeetNew >= p.Y {
// Korrektur: Wir setzen den Spieler exakt AUF die Plattform
newY = p.Y - PlayerHeight
s.VelY = 0 s.VelY = 0
landed = true landed = true
break isGrounded = true
break // Landung erfolgreich
}
} }
} }
} }
// B. Boden Landung // ============================================================
// BODEN KOLLISION
// ============================================================
if !landed { if !landed {
if newY >= PlayerYBase { if newY >= PlayerYBase {
newY = PlayerYBase newY = PlayerYBase
s.VelY = 0 s.VelY = 0
isGrounded = true
} }
} }
// Neue Position setzen
s.PosY = newY s.PosY = newY
} }