Private
Public Access
1
0

Implement core game functionalities: client prediction, coin collection, scoring, game state synchronization, and player management.

This commit is contained in:
Sebastian Unterschütz
2026-01-01 16:46:39 +01:00
parent 4b2995846e
commit 5e6b8a2304
9 changed files with 902 additions and 203 deletions

View File

@@ -55,9 +55,10 @@ type LoginPayload struct {
// Input vom Spieler während des Spiels
type ClientInput struct {
Type string `json:"type"` // "JUMP", "START"
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 {
@@ -66,21 +67,27 @@ type JoinRequest struct {
}
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"`
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"`
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)
}