Adjust physics constants and movement logic for 20 TPS, scale velocities and gravity by a factor of 3, and update cache-busting version for client assets.
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m0s
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m0s
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user