Private
Public Access
1
0

fix game
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m15s

This commit is contained in:
Sebastian Unterschütz
2026-03-21 22:39:01 +01:00
parent ce092c8366
commit 7a86a8596e
3 changed files with 19 additions and 4 deletions

View File

@@ -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 ---

View File

@@ -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)

View File

@@ -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 {