fix game
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m15s
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m15s
This commit is contained in:
@@ -74,6 +74,8 @@ func (g *Game) UpdateGame() {
|
||||
g.btnDownActive = false
|
||||
|
||||
// --- 4. INPUT SENDEN (MIT CLIENT PREDICTION) ---
|
||||
// Prediction läuft bei jedem Frame (60 TPS) für flüssige Darstellung.
|
||||
// Netz-Send wird auf ~20/sek gedrosselt um Server-Last zu begrenzen.
|
||||
if g.connected {
|
||||
g.predictionMutex.Lock()
|
||||
// Sequenznummer erhöhen
|
||||
@@ -86,10 +88,23 @@ func (g *Game) UpdateGame() {
|
||||
// Input für History speichern (für Server-Reconciliation)
|
||||
g.pendingInputs[input.Sequence] = input
|
||||
|
||||
// Cap: nie mehr als 120 unbestätigte Inputs ansammeln
|
||||
if len(g.pendingInputs) > 120 {
|
||||
oldest := g.inputSequence - 120
|
||||
for seq := range g.pendingInputs {
|
||||
if seq < oldest {
|
||||
delete(g.pendingInputs, seq)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g.predictionMutex.Unlock()
|
||||
|
||||
// Input an Server senden
|
||||
g.SendInputWithSequence(input)
|
||||
// Netz-Throttle: max 20 Inputs/Sek senden
|
||||
if time.Since(g.lastInputTime) >= 50*time.Millisecond {
|
||||
g.lastInputTime = time.Now()
|
||||
g.SendInputWithSequence(input)
|
||||
}
|
||||
}
|
||||
|
||||
// --- 5. KAMERA LOGIK ---
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func main() {
|
||||
ebiten.SetWindowSize(ScreenWidth, ScreenHeight)
|
||||
ebiten.SetWindowTitle("Escape From Teacher")
|
||||
ebiten.SetTPS(20)
|
||||
ebiten.SetTPS(60)
|
||||
ebiten.SetVsyncEnabled(true)
|
||||
if err := ebiten.RunGame(NewGame()); err != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
@@ -27,7 +27,7 @@ func main() {
|
||||
|
||||
// WICHTIG: Keine feste WindowSize auf WASM - Layout() regelt die Größe dynamisch
|
||||
ebiten.SetWindowTitle("Escape From Teacher")
|
||||
ebiten.SetTPS(20)
|
||||
ebiten.SetTPS(60)
|
||||
ebiten.SetVsyncEnabled(true)
|
||||
|
||||
if err := ebiten.RunGame(game); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user