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:
@@ -33,6 +33,17 @@ type AssetManifest struct {
|
||||
type LevelObject struct {
|
||||
AssetID string
|
||||
X, Y float64
|
||||
|
||||
// Für bewegende Plattformen
|
||||
MovingPlatform *MovingPlatformData `json:"moving_platform,omitempty"`
|
||||
}
|
||||
|
||||
type MovingPlatformData struct {
|
||||
StartX float64 `json:"start_x"` // Start-Position X (relativ zum Chunk)
|
||||
StartY float64 `json:"start_y"` // Start-Position Y
|
||||
EndX float64 `json:"end_x"` // End-Position X
|
||||
EndY float64 `json:"end_y"` // End-Position Y
|
||||
Speed float64 `json:"speed"` // Geschwindigkeit (Einheiten pro Sekunde)
|
||||
}
|
||||
type Chunk struct {
|
||||
ID string
|
||||
@@ -62,34 +73,51 @@ type ClientInput struct {
|
||||
}
|
||||
|
||||
type JoinRequest struct {
|
||||
Name string `json:"name"`
|
||||
RoomID string `json:"room_id"`
|
||||
Name string `json:"name"`
|
||||
RoomID string `json:"room_id"`
|
||||
GameMode string `json:"game_mode"` // "solo" oder "coop"
|
||||
IsHost bool `json:"is_host"`
|
||||
TeamName string `json:"team_name"`
|
||||
}
|
||||
|
||||
type PlayerState struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
VX float64 `json:"vx"`
|
||||
VY float64 `json:"vy"`
|
||||
State string `json:"state"`
|
||||
OnGround bool `json:"on_ground"`
|
||||
LastInputSeq uint32 `json:"last_input_seq"` // Letzte verarbeitete Input-Sequenz
|
||||
Score int `json:"score"` // Punkte des Spielers
|
||||
IsAlive bool `json:"is_alive"` // Lebt der Spieler noch?
|
||||
IsSpectator bool `json:"is_spectator"` // Ist im Zuschauer-Modus
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
VX float64 `json:"vx"`
|
||||
VY float64 `json:"vy"`
|
||||
State string `json:"state"`
|
||||
OnGround bool `json:"on_ground"`
|
||||
OnWall bool `json:"on_wall"` // Ist an einer Wand
|
||||
LastInputSeq uint32 `json:"last_input_seq"` // Letzte verarbeitete Input-Sequenz
|
||||
Score int `json:"score"` // Punkte des Spielers
|
||||
IsAlive bool `json:"is_alive"` // Lebt der Spieler noch?
|
||||
IsSpectator bool `json:"is_spectator"` // Ist im Zuschauer-Modus
|
||||
HasDoubleJump bool `json:"has_double_jump"` // Hat Double Jump Powerup
|
||||
HasGodMode bool `json:"has_godmode"` // Hat Godmode Powerup
|
||||
}
|
||||
|
||||
type GameState struct {
|
||||
RoomID string `json:"room_id"`
|
||||
Players map[string]PlayerState `json:"players"`
|
||||
Status string `json:"status"`
|
||||
TimeLeft int `json:"time_left"`
|
||||
WorldChunks []ActiveChunk `json:"world_chunks"`
|
||||
HostID string `json:"host_id"`
|
||||
ScrollX float64 `json:"scroll_x"`
|
||||
CollectedCoins map[string]bool `json:"collected_coins"` // Welche Coins wurden eingesammelt (Key: ChunkID_ObjectIndex)
|
||||
RoomID string `json:"room_id"`
|
||||
Players map[string]PlayerState `json:"players"`
|
||||
Status string `json:"status"`
|
||||
TimeLeft int `json:"time_left"`
|
||||
WorldChunks []ActiveChunk `json:"world_chunks"`
|
||||
HostID string `json:"host_id"`
|
||||
ScrollX float64 `json:"scroll_x"`
|
||||
CollectedCoins map[string]bool `json:"collected_coins"` // Welche Coins wurden eingesammelt (Key: ChunkID_ObjectIndex)
|
||||
CollectedPowerups map[string]bool `json:"collected_powerups"` // Welche Powerups wurden eingesammelt
|
||||
MovingPlatforms []MovingPlatformSync `json:"moving_platforms"` // Bewegende Plattformen
|
||||
}
|
||||
|
||||
// MovingPlatformSync: Synchronisiert die Position einer bewegenden Plattform
|
||||
type MovingPlatformSync struct {
|
||||
ChunkID string `json:"chunk_id"`
|
||||
ObjectIdx int `json:"object_idx"`
|
||||
AssetID string `json:"asset_id"`
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
}
|
||||
|
||||
// Leaderboard-Eintrag
|
||||
@@ -105,4 +133,22 @@ type ScoreSubmission struct {
|
||||
PlayerName string `json:"player_name"`
|
||||
PlayerCode string `json:"player_code"`
|
||||
Score int `json:"score"`
|
||||
Name string `json:"name"` // Alternativer Name-Feld (für Kompatibilität)
|
||||
Mode string `json:"mode"` // "solo" oder "coop"
|
||||
}
|
||||
|
||||
// Start-Request vom Client
|
||||
type StartRequest struct {
|
||||
RoomID string `json:"room_id"`
|
||||
}
|
||||
|
||||
// Leaderboard-Request vom Client
|
||||
type LeaderboardRequest struct {
|
||||
Mode string `json:"mode"` // "solo" oder "coop"
|
||||
ResponseChannel string `json:"response_channel"`
|
||||
}
|
||||
|
||||
// Leaderboard-Response vom Server
|
||||
type LeaderboardResponse struct {
|
||||
Entries []LeaderboardEntry `json:"entries"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user