Add platform-specific implementations for assets, audio, WebSocket, and rendering on Desktop and WebAssembly platforms. Introduce embedded assets for WebAssembly and native file handling for Desktop. Add platform-specific chunk loading and game state synchronization.
This commit is contained in:
@@ -43,3 +43,33 @@ func (g *Game) loadOrCreatePlayerCode() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// loadPlayerName lädt gespeicherten Spielernamen (WebAssembly Version)
|
||||
func (g *Game) loadPlayerName() string {
|
||||
const storageKey = "escape_from_teacher_player_name"
|
||||
|
||||
if jsGlobal := js.Global(); !jsGlobal.IsUndefined() {
|
||||
localStorage := jsGlobal.Get("localStorage")
|
||||
if !localStorage.IsUndefined() {
|
||||
stored := localStorage.Call("getItem", storageKey)
|
||||
if !stored.IsNull() && stored.String() != "" {
|
||||
log.Printf("👤 Spielername aus LocalStorage geladen: %s", stored.String())
|
||||
return stored.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// savePlayerName speichert Spielernamen (WebAssembly Version)
|
||||
func (g *Game) savePlayerName(name string) {
|
||||
const storageKey = "escape_from_teacher_player_name"
|
||||
|
||||
if jsGlobal := js.Global(); !jsGlobal.IsUndefined() {
|
||||
localStorage := jsGlobal.Get("localStorage")
|
||||
if !localStorage.IsUndefined() {
|
||||
localStorage.Call("setItem", storageKey, name)
|
||||
log.Printf("💾 Spielername in LocalStorage gespeichert: %s", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user