Private
Public Access
1
0

Integrate shared physics engine for player movement and collision handling, refine 20 TPS gameplay logic, and enhance client prediction with server-reconciliation updates.
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 7m51s

This commit is contained in:
Sebastian Unterschütz
2026-01-06 21:37:32 +01:00
parent 23d42d42e7
commit 023996229a
13 changed files with 685 additions and 251 deletions

View File

@@ -88,11 +88,14 @@ type Game struct {
predictedVX float64
predictedVY float64
predictedGround bool
predictedOnWall bool
currentSpeed float64 // Aktuelle Scroll-Geschwindigkeit vom Server
inputSequence uint32 // Sequenznummer für Inputs
pendingInputs map[uint32]InputState // Noch nicht bestätigte Inputs
lastServerSeq uint32 // Letzte vom Server bestätigte Sequenz
predictionMutex sync.Mutex // Mutex für pendingInputs
lastRecvSeq uint32 // Letzte empfangene Server-Sequenznummer (für Out-of-Order-Erkennung)
lastInputTime time.Time // Letzter Input-Send (für 20 TPS Throttling)
// Smooth Correction
correctionX float64 // Verbleibende Korrektur in X
@@ -119,6 +122,18 @@ type Game struct {
joyTouchID ebiten.TouchID
btnJumpActive bool
keyboardUsed bool // Wurde Tastatur benutzt?
// Debug Stats
showDebug bool // Debug-Overlay anzeigen (F3 zum Umschalten)
fpsCounter int // Frame-Zähler
fpsSampleTime time.Time // Letzter FPS-Sample
currentFPS float64 // Aktuelle FPS
lastUpdateTime time.Time // Letzte Server-Update Zeit
updateLatency float64 // Latenz zum letzten Update (ms)
correctionCount int // Anzahl der Korrekturen
outOfOrderCount int // Anzahl verworfener Out-of-Order Pakete
totalUpdates int // Gesamtzahl empfangener Updates
pendingInputCount int // Anzahl pending Inputs
}
func NewGame() *Game {
@@ -142,6 +157,10 @@ func NewGame() *Game {
// Audio System
audio: NewAudioSystem(),
// Debug Stats
fpsSampleTime: time.Now(),
lastUpdateTime: time.Now(),
joyBaseX: 150, joyBaseY: ScreenHeight - 150,
joyStickX: 150, joyStickY: ScreenHeight - 150,
}
@@ -161,6 +180,24 @@ func NewGame() *Game {
// --- UPDATE ---
func (g *Game) Update() error {
// FPS Tracking
g.fpsCounter++
if time.Since(g.fpsSampleTime) >= time.Second {
g.currentFPS = float64(g.fpsCounter) / time.Since(g.fpsSampleTime).Seconds()
g.fpsCounter = 0
g.fpsSampleTime = time.Now()
}
// Debug Toggle (F3)
if inpututil.IsKeyJustPressed(ebiten.KeyF3) {
g.showDebug = !g.showDebug
}
// Pending Inputs zählen für Debug
g.predictionMutex.Lock()
g.pendingInputCount = len(g.pendingInputs)
g.predictionMutex.Unlock()
// Game Over Handling
if g.appState == StateGame && g.gameState.Status == "GAMEOVER" {
// Back Button (oben links) - Touch Support
@@ -594,7 +631,10 @@ func (g *Game) DrawLobby(screen *ebiten.Image) {
text.Draw(screen, "< Back", basicfont.Face7x13, 65, 75, ColText)
}
func (g *Game) Layout(w, h int) (int, int) { return ScreenWidth, ScreenHeight }
func (g *Game) Layout(w, h int) (int, int) {
// Nutze die GESAMTE Bildschirmfläche ohne Einschränkungen
return w, h
}
// --- HELPER ---