fix game
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m20s
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m20s
This commit is contained in:
@@ -104,7 +104,22 @@ func (g *Game) UpdateGame() {
|
||||
// Kamera hart setzen
|
||||
g.camX = targetCam
|
||||
|
||||
// --- 6. PARTIKEL UPDATEN ---
|
||||
// --- 6. CORRECTION OFFSET ABKLINGEN ---
|
||||
// Der visuelle Offset sorgt dafür dass Server-Korrekturen sanft und unsichtbar sind.
|
||||
// Decay: 0.85 pro Frame → ~5 Frames zum Halbieren bei 60fps (≈80ms)
|
||||
const correctionDecay = 0.85
|
||||
g.predictionMutex.Lock()
|
||||
g.correctionOffsetX *= correctionDecay
|
||||
g.correctionOffsetY *= correctionDecay
|
||||
if g.correctionOffsetX*g.correctionOffsetX < 0.09 {
|
||||
g.correctionOffsetX = 0
|
||||
}
|
||||
if g.correctionOffsetY*g.correctionOffsetY < 0.09 {
|
||||
g.correctionOffsetY = 0
|
||||
}
|
||||
g.predictionMutex.Unlock()
|
||||
|
||||
// --- 7. PARTIKEL UPDATEN ---
|
||||
g.UpdateParticles(1.0 / 60.0) // Delta time: ~16ms
|
||||
|
||||
// --- 7. PARTIKEL SPAWNEN (State Changes Detection) ---
|
||||
@@ -335,12 +350,12 @@ func (g *Game) DrawGame(screen *ebiten.Image) {
|
||||
vy := p.VY
|
||||
onGround := p.OnGround
|
||||
|
||||
// Für lokalen Spieler: Verwende Client-Prediction Position
|
||||
// Die Reconciliation wird in ReconcileWithServer() (connection_*.go) gemacht
|
||||
// Für lokalen Spieler: Verwende Client-Prediction + visuellen Korrektur-Offset
|
||||
// correctionOffset sorgt dafür dass Server-Korrekturen sanft aussehen
|
||||
if p.Name == g.playerName {
|
||||
g.predictionMutex.Lock()
|
||||
posX = g.predictedX
|
||||
posY = g.predictedY
|
||||
posX = g.predictedX + g.correctionOffsetX
|
||||
posY = g.predictedY + g.correctionOffsetY
|
||||
g.predictionMutex.Unlock()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user