Introduce core components for "Escape From Teacher" game: server, client, physics, asset system, and protocol definitions. Add Docker-Compose setup for Redis and NATS infrastructure.
This commit is contained in:
6
pkg/game/assets.go
Normal file
6
pkg/game/assets.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package game
|
||||
|
||||
// Manifest ist die ganze Konfigurationsdatei
|
||||
type Manifest struct {
|
||||
Assets map[string]AssetDefinition `json:"assets"`
|
||||
}
|
||||
86
pkg/game/data.go
Normal file
86
pkg/game/data.go
Normal file
@@ -0,0 +1,86 @@
|
||||
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"
|
||||
RoomID string `json:"room_id"`
|
||||
PlayerID string `json:"player_id"`
|
||||
}
|
||||
|
||||
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"`
|
||||
State string `json:"state"`
|
||||
OnGround bool `json:"on_ground"`
|
||||
}
|
||||
|
||||
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"`
|
||||
}
|
||||
Reference in New Issue
Block a user