Add analog joystick support with fine control adjustments, improve prediction smoothing, reduce correction thresholds, and enhance lobby and overlay UI responsiveness.
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m23s
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m23s
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
// ApplyInput wendet einen Input auf den vorhergesagten Zustand an
|
||||
func (g *Game) ApplyInput(input InputState) {
|
||||
// Horizontale Bewegung
|
||||
// Horizontale Bewegung mit analogem Joystick
|
||||
moveX := 0.0
|
||||
if input.Left {
|
||||
moveX = -1.0
|
||||
@@ -15,6 +15,12 @@ func (g *Game) ApplyInput(input InputState) {
|
||||
moveX = 1.0
|
||||
}
|
||||
|
||||
// Wenn Joystick benutzt wird, überschreibe moveX mit analogem Wert
|
||||
if input.JoyX != 0 {
|
||||
moveX = input.JoyX
|
||||
}
|
||||
|
||||
// Geschwindigkeit skaliert mit Joystick-Intensität
|
||||
speed := config.RunSpeed + (moveX * 4.0)
|
||||
g.predictedX += speed
|
||||
|
||||
@@ -107,8 +113,8 @@ func (g *Game) ReconcileWithServer(serverState game.PlayerState) {
|
||||
diffX := replayX - g.predictedX
|
||||
diffY := replayY - g.predictedY
|
||||
|
||||
// Nur korrigieren wenn Differenz signifikant (> 5 Pixel)
|
||||
const threshold = 5.0
|
||||
// Nur korrigieren wenn Differenz signifikant (reduzierter Threshold für weniger Ruckeln)
|
||||
const threshold = 2.0 // Reduziert von 5.0 auf 2.0
|
||||
if diffX*diffX+diffY*diffY > threshold*threshold {
|
||||
// Speichere Korrektur für sanfte Interpolation
|
||||
g.correctionX = diffX
|
||||
|
||||
Reference in New Issue
Block a user