diff options
author | metamuffin <metamuffin@disroot.org> | 2025-06-03 21:14:17 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-06-03 21:14:17 +0200 |
commit | 09b6da1aab7bb9b89c3b2afbda5d3ff7913ad7e8 (patch) | |
tree | 083f35c352657cb3b800cdfce6f08892785e8c49 /test-client | |
parent | e0201e044482b1a577dac7574bb56d44a20bf011 (diff) | |
download | hurrycurry-09b6da1aab7bb9b89c3b2afbda5d3ff7913ad7e8.tar hurrycurry-09b6da1aab7bb9b89c3b2afbda5d3ff7913ad7e8.tar.bz2 hurrycurry-09b6da1aab7bb9b89c3b2afbda5d3ff7913ad7e8.tar.zst |
update test-client to character struct
Diffstat (limited to 'test-client')
-rw-r--r-- | test-client/main.ts | 4 | ||||
-rw-r--r-- | test-client/protocol.ts | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/test-client/main.ts b/test-client/main.ts index ef38494d..66e3e989 100644 --- a/test-client/main.ts +++ b/test-client/main.ts @@ -50,7 +50,7 @@ document.addEventListener("DOMContentLoaded", async () => { ws.onclose = () => console.log("close") ws.onopen = () => { console.log("open") - send({ type: "join", name: "test", character: Math.floor(Math.random() * 255), class: "chef" }) + send({ type: "join", name: "test", character: { color: Math.floor(Math.random() * 100), hairstyle: 0, headwear: 0 }, class: "chef" }) } canvas = document.createElement("canvas"); @@ -156,7 +156,7 @@ function packet(p: PacketC) { id: p.id, position: { x: p.position[0], y: p.position[1], }, anim_position: { x: p.position[0], y: p.position[1] }, - character: p.character, + character: p.character.color, class: p.class, name: p.name, rot: 0, diff --git a/test-client/protocol.ts b/test-client/protocol.ts index a3302628..1cfdab79 100644 --- a/test-client/protocol.ts +++ b/test-client/protocol.ts @@ -37,7 +37,7 @@ export interface Gamedata { } export type PacketS = - { type: "join", name: string, character: number, class: PlayerClass } // Spawns a new character. The server replies with "joined". Dont send it to spectate. + { type: "join", name: string, character: Character, class: PlayerClass } // Spawns a new character. The server replies with "joined". Dont send it to spectate. | { type: "leave", player: PlayerID } // Despawns a character | { type: "idle", paused: boolean } // Indicates that this player is actively participating in the game right now. | { type: "movement", player: PlayerID, pos: Vec2, dir: Vec2, boost: boolean } @@ -50,7 +50,7 @@ export type PacketC = { type: "version", minor: number, major: number, supports_bincode?: boolean } // Sent once after connecting to ensure you client is compatible | { type: "joined", id: PlayerID } // Informs you about the id of the character you spawned | { type: "data", data: Gamedata } // Game data was changed - | { type: "add_player", id: PlayerID, name: string, position: Vec2, character: number, class: PlayerClass } // Somebody else joined (or was already in the game) + | { type: "add_player", id: PlayerID, name: string, position: Vec2, character: Character, class: PlayerClass } // Somebody else joined (or was already in the game) | { type: "remove_player", id: PlayerID } // Somebody left | { type: "movement", player: PlayerID, pos: Vec2, rot: number, boost: boolean, dir: Vec2 } // Update the movement of a players (your own position is included here) | { type: "movement_sync" } // Your movement is difference on the server, you should update your position from a `position` packet @@ -71,6 +71,12 @@ export type PacketC = | { type: "set_ingame", state: boolean, lobby: boolean } // Set to false when entering the game or switching maps | { type: "pause", state: boolean } // Set game paused so clients dont increment timers +export interface Character { + color: number, + headwear: number, + hairstyle: number +} + export type Menu = { menu: "document", data: DocumentElement } | { menu: "score", data: Score } |