diff --git a/cmd/client/prediction.go b/cmd/client/prediction.go index f70bb11..3d0c4cb 100644 --- a/cmd/client/prediction.go +++ b/cmd/client/prediction.go @@ -21,7 +21,8 @@ func (g *Game) ApplyInput(input InputState) { } // Geschwindigkeit skaliert mit Joystick-Intensität - speed := config.RunSpeed + (moveX * 4.0) + // war 4.0 bei 60 TPS (4.0 * 3 = 12.0) + speed := config.RunSpeed + (moveX * 12.0) g.predictedX += speed // Gravitation @@ -32,12 +33,12 @@ func (g *Game) ApplyInput(input InputState) { // Fast Fall if input.Down { - g.predictedVY = 15.0 + g.predictedVY = 45.0 // war 15.0 bei 60 TPS (15.0 * 3) } // Sprung if input.Jump && g.predictedGround { - g.predictedVY = -14.0 + g.predictedVY = -42.0 // war -14.0 bei 60 TPS (-14.0 * 3) g.predictedGround = false } diff --git a/cmd/client/web/game.js b/cmd/client/web/game.js index 48a72e7..ba4d6e9 100644 --- a/cmd/client/web/game.js +++ b/cmd/client/web/game.js @@ -234,7 +234,7 @@ window.onWasmReady = function() { }; // Cache Management - Version wird bei jedem Build aktualisiert -const CACHE_VERSION = 1767636391983; // Wird durch Build-Prozess ersetzt +const CACHE_VERSION = 1767637179526; // Wird durch Build-Prozess ersetzt // Fetch mit Cache-Busting async function fetchWithCache(url) { diff --git a/cmd/client/web/index.html b/cmd/client/web/index.html index 820cfed..2f2d503 100644 --- a/cmd/client/web/index.html +++ b/cmd/client/web/index.html @@ -291,7 +291,7 @@ diff --git a/cmd/client/web/main.wasm b/cmd/client/web/main.wasm index 6c05071..e3e9e3e 100755 Binary files a/cmd/client/web/main.wasm and b/cmd/client/web/main.wasm differ diff --git a/pkg/config/config.go b/pkg/config/config.go index 4bcf1dc..631b70c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -8,15 +8,17 @@ const ( AssetPath = "./cmd/client/web/assets/assets.json" ChunkDir = "./cmd/client/web/assets/chunks" - // Physics - Gravity = 0.5 - MaxFall = 15.0 + // Physics (angepasst für 20 TPS statt 60 TPS) + // Bei 20 TPS ist jeder Tick 3x länger (50ms statt 16.67ms) + // Geschwindigkeiten müssen mit 3 multipliziert werden + Gravity = 1.5 // war 0.5 bei 60 TPS + MaxFall = 45.0 // war 15.0 bei 60 TPS TileSize = 64 // Gameplay - RunSpeed = 7.0 + RunSpeed = 21.0 // war 7.0 bei 60 TPS (7.0 * 3) StartTime = 5 // Sekunden Countdown - TickRate = time.Millisecond * 16 // ~60 FPS + TickRate = time.Millisecond * 50 // 20 TPS (war 16ms für 60 TPS) // NATS Subjects Templates SubjectInput = "game.room.%s.input" diff --git a/pkg/server/room.go b/pkg/server/room.go index d5cac70..aa62dcb 100644 --- a/pkg/server/room.go +++ b/pkg/server/room.go @@ -261,17 +261,17 @@ func (r *Room) HandleInput(input game.ClientInput) { switch input.Type { case "JUMP": if p.OnGround { - p.VY = -14.0 + p.VY = -42.0 // war -14.0 bei 60 TPS (-14.0 * 3) p.OnGround = false p.DoubleJumpUsed = false // Reset double jump on ground jump } else if p.HasDoubleJump && !p.DoubleJumpUsed { // Double Jump in der Luft - p.VY = -14.0 + p.VY = -42.0 // war -14.0 bei 60 TPS (-14.0 * 3) p.DoubleJumpUsed = true log.Printf("⚡ %s verwendet Double Jump!", p.Name) } case "DOWN": - p.VY = 15.0 + p.VY = 45.0 // war 15.0 bei 60 TPS (15.0 * 3) case "LEFT_DOWN": p.InputX = -1 case "LEFT_UP": @@ -356,9 +356,10 @@ func (r *Room) Update() { // X Bewegung // Symmetrische Geschwindigkeit: Links = Rechts - // Nach rechts: CurrentSpeed + 11, Nach links: CurrentSpeed - 11 + // Nach rechts: CurrentSpeed + 33, Nach links: CurrentSpeed - 33 // Verwendet r.CurrentSpeed statt config.RunSpeed für dynamische Geschwindigkeit - currentSpeed := r.CurrentSpeed + (p.InputX * 11.0) + // war 11.0 bei 60 TPS (11.0 * 3 = 33.0) + currentSpeed := r.CurrentSpeed + (p.InputX * 33.0) nextX := p.X + currentSpeed hitX, typeX := r.CheckCollision(nextX+r.pDrawOffX+r.pHitboxOffX, p.Y+r.pDrawOffY+r.pHitboxOffY, r.pW, r.pH) @@ -407,13 +408,13 @@ func (r *Room) Update() { if p.OnWall { // Wandrutschen (langsame Fallgeschwindigkeit) p.VY += config.Gravity * 0.3 // 30% Gravität an der Wand - if p.VY > 3.0 { - p.VY = 3.0 // Maximal 3.0 beim Rutschen + if p.VY > 9.0 { // war 3.0 bei 60 TPS (3.0 * 3) + p.VY = 9.0 // Maximal 9.0 beim Rutschen } // Hochklettern wenn nach oben gedrückt (InputX in Wandrichtung) if p.InputX != 0 { - p.VY = -5.0 // Kletter-Geschwindigkeit nach oben + p.VY = -15.0 // war -5.0 bei 60 TPS (-5.0 * 3) } } else { // Normal: Volle Gravität