package game import "image/color" type Vec2 struct { X, Y float64 `json:"x,y"` } type Rect struct { OffsetX, OffsetY, W, H float64 Type string } // Type hinzugefügt aus letztem Schritt type HexColor struct { R, G, B, A uint8 `json:"r,g,b,a"` } func (h HexColor) ToRGBA() color.RGBA { if h.A == 0 { return color.RGBA{h.R, h.G, h.B, 255} } return color.RGBA{h.R, h.G, h.B, h.A} } // --- ASSETS & CHUNKS (Bleiben gleich) --- type AssetDefinition struct { ID, Type, Filename string Scale, ProcWidth, ProcHeight, DrawOffX, DrawOffY float64 Color HexColor Hitbox Rect } type AssetManifest struct { Assets map[string]AssetDefinition `json:"assets"` } type LevelObject struct { AssetID string X, Y float64 } type Chunk struct { ID string Width int Objects []LevelObject } type ActiveChunk struct { ChunkID string X float64 } // --- NETZWERK & GAMEPLAY --- // Login Request (Client -> Server beim Verbinden) type LoginPayload struct { Action string `json:"action"` // "CREATE" oder "JOIN" RoomID string `json:"room_id"` // Leer bei CREATE, Code bei JOIN Name string `json:"name"` // Spielername } // Input vom Spieler während des Spiels type ClientInput struct { Type string `json:"type"` // "JUMP", "START", "LEFT_DOWN", "RIGHT_DOWN", etc. RoomID string `json:"room_id"` PlayerID string `json:"player_id"` Sequence uint32 `json:"sequence"` // Sequenznummer für Client Prediction } type JoinRequest struct { Name string `json:"name"` RoomID string `json:"room_id"` } 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 } 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) }