Private
Public Access
1
0

add offline mode for solo play with local game state simulation
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 1m47s

This commit is contained in:
Sebastian Unterschütz
2026-04-22 12:37:52 +02:00
parent e295d1ad61
commit de87b76005
4 changed files with 147 additions and 6 deletions

View File

@@ -73,6 +73,7 @@ type Game struct {
roomID string
activeField string // "name" oder "room" oder "teamname"
gameMode string // "solo" oder "coop"
isOffline bool // Läuft das Spiel lokal ohne Server?
isHost bool
teamName string // Team-Name für Coop beim Game Over
@@ -351,15 +352,13 @@ func (g *Game) updateMenu() {
btnY := ScreenHeight/2 - 20
if isHit(soloX, btnY, btnW, btnH) {
// SOLO MODE
// SOLO MODE (Offline by default)
if g.playerName == "" {
g.playerName = "Player"
}
g.gameMode = "solo"
g.roomID = fmt.Sprintf("solo_%d", time.Now().UnixNano())
g.isHost = true
g.appState = StateGame
go g.connectAndStart()
g.startOfflineGame()
} else if isHit(coopX, btnY, btnW, btnH) {
// CO-OP MODE
if g.playerName == "" {
@@ -926,6 +925,10 @@ func (g *Game) SendCommand(cmdType string) {
func (g *Game) SendInputWithSequence(input InputState) {
if !g.connected {
// Im Offline-Modus den Jump-Sound trotzdem lokal abspielen
if input.Jump && g.isOffline {
g.audio.PlayJump()
}
return
}