fix game
Some checks failed
Dynamic Branch Deploy / build-and-deploy (push) Failing after 8m17s
Some checks failed
Dynamic Branch Deploy / build-and-deploy (push) Failing after 8m17s
This commit is contained in:
@@ -126,9 +126,15 @@ type Game struct {
|
||||
joyStickX, joyStickY float64
|
||||
joyActive bool
|
||||
joyTouchID ebiten.TouchID
|
||||
joyRadius float64 // Joystick-Radius (skaliert mit Screen)
|
||||
btnJumpActive bool
|
||||
keyboardUsed bool // Wurde Tastatur benutzt?
|
||||
lastCanvasHeight int // Cache der Canvas-Höhe für Touch-Input
|
||||
btnJumpPressed bool // Jump wird gerade gehalten (visuelles Feedback)
|
||||
btnDownActive bool // Down/FastFall-Button gedrückt
|
||||
keyboardUsed bool // Wurde Tastatur benutzt?
|
||||
lastCanvasHeight int // Cache der Canvas-Höhe für Touch-Input
|
||||
lastCanvasWidth int // Cache der Canvas-Breite für Touch-Input
|
||||
downBtnX, downBtnY float64 // Zentrum des Down-Buttons
|
||||
downBtnR float64 // Radius des Down-Buttons
|
||||
|
||||
// Debug Stats
|
||||
showDebug bool // Debug-Overlay anzeigen (F3 zum Umschalten)
|
||||
@@ -844,13 +850,61 @@ func generateRoomCode() string {
|
||||
return string(code)
|
||||
}
|
||||
|
||||
func (g *Game) connectAndStart() {
|
||||
// Initiale predicted Position
|
||||
// resetForNewGame setzt den gesamten Spiel-State zurück ohne die Seite neu zu laden.
|
||||
// Muss vor jeder neuen Verbindung aufgerufen werden.
|
||||
func (g *Game) resetForNewGame() {
|
||||
// Alte Verbindung sauber trennen
|
||||
g.disconnectFromServer()
|
||||
|
||||
// Prediction-State zurücksetzen
|
||||
g.predictionMutex.Lock()
|
||||
g.pendingInputs = make(map[uint32]InputState)
|
||||
g.inputSequence = 0
|
||||
g.lastServerSeq = 0
|
||||
g.predictedX = 100
|
||||
g.predictedY = 200
|
||||
g.predictedVX = 0
|
||||
g.predictedVY = 0
|
||||
g.predictedGround = false
|
||||
g.predictedOnWall = false
|
||||
g.currentSpeed = 0
|
||||
g.correctionOffsetX = 0
|
||||
g.correctionOffsetY = 0
|
||||
g.predictionMutex.Unlock()
|
||||
|
||||
// KRITISCH: lastRecvSeq zurücksetzen!
|
||||
// Ohne diesen Reset ignoriert die Out-of-Order-Prüfung alle Nachrichten
|
||||
// des neuen Spiels (neue Sequenzen < alter lastRecvSeq).
|
||||
g.lastRecvSeq = 0
|
||||
|
||||
// Spieler-State zurücksetzen
|
||||
g.scoreSubmitted = false
|
||||
g.lastStatus = ""
|
||||
g.correctionCount = 0
|
||||
g.outOfOrderCount = 0
|
||||
g.totalUpdates = 0
|
||||
|
||||
// GameState leeren
|
||||
g.stateMutex.Lock()
|
||||
g.gameState = game.GameState{Players: make(map[string]game.PlayerState)}
|
||||
g.stateMutex.Unlock()
|
||||
|
||||
// Leaderboard leeren
|
||||
g.leaderboardMutex.Lock()
|
||||
g.leaderboard = make([]game.LeaderboardEntry, 0)
|
||||
g.leaderboardMutex.Unlock()
|
||||
|
||||
// Partikel leeren
|
||||
g.particlesMutex.Lock()
|
||||
g.particles = nil
|
||||
g.particlesMutex.Unlock()
|
||||
g.lastCollectedCoins = make(map[string]bool)
|
||||
g.lastCollectedPowerups = make(map[string]bool)
|
||||
g.lastPlayerStates = make(map[string]game.PlayerState)
|
||||
}
|
||||
|
||||
func (g *Game) connectAndStart() {
|
||||
g.resetForNewGame()
|
||||
|
||||
// Verbindung über plattformspezifische Implementierung
|
||||
g.connectToServer()
|
||||
|
||||
Reference in New Issue
Block a user