diff options
Diffstat (limited to 'test-client')
-rw-r--r-- | test-client/main.ts | 6 | ||||
-rw-r--r-- | test-client/protocol.ts | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/test-client/main.ts b/test-client/main.ts index f0f481b4..00699b60 100644 --- a/test-client/main.ts +++ b/test-client/main.ts @@ -156,7 +156,7 @@ function packet(p: PacketC) { case "remove_player": players.delete(p.id) break; - case "position": { + case "movement": { const pl = players.get(p.player)! const pos = { x: p.pos[0], y: p.pos[1] } // const dist = length(sub_v2(pl.position, pos));a @@ -165,7 +165,7 @@ function packet(p: PacketC) { if (p.player == my_id) return last_server_sent_position = pos pl.position.x = pos.x pl.position.y = pos.y - pl.boosting = p.boosting + pl.boosting = p.boost pl.rot = p.rot break; } @@ -307,7 +307,7 @@ function set_interact(edge: boolean) { function tick_update() { const p = players.get(my_id) if (!p) return - send({ player: my_id, type: "movement", pos: [p.position.x, p.position.y], direction: [p.direction.x, p.direction.y], boosting: p.boosting }) + send({ player: my_id, type: "movement", pos: [p.position.x, p.position.y], dir: [p.direction.x, p.direction.y], boost: p.boosting }) } function frame_update(dt: number) { diff --git a/test-client/protocol.ts b/test-client/protocol.ts index 353c9100..e16f80d3 100644 --- a/test-client/protocol.ts +++ b/test-client/protocol.ts @@ -38,7 +38,7 @@ export interface Gamedata { export type PacketS = { type: "join", name: string, character: number } // Spawns a new character. The server replies with "joined". Dont send it to spectate. | { type: "leave", player: PlayerID } // Despawns a character - | { type: "movement", player: PlayerID, pos: Vec2, direction: Vec2, boosting: boolean } + | { type: "movement", player: PlayerID, pos: Vec2, dir: Vec2, boost: boolean } | { type: "interact", player: PlayerID, pos?: Vec2 } // Interact with some tile. pos is a position when pressing and null when releasing interact button | { type: "communicate", player: PlayerID, message?: Message, persist: boolean } // Send a message | { type: "replay_tick", dt: number } // Steps forward in replay. @@ -49,7 +49,8 @@ export type PacketC = | { type: "data", data: Gamedata } // Game data was changed | { type: "add_player", id: PlayerID, name: string, position: Vec2, character: number } // Somebody else joined (or was already in the game) | { type: "remove_player", id: PlayerID } // Somebody left - | { type: "position", player: PlayerID, pos: Vec2, rot: number, boosting: boolean } // Update the position of a players (your own position is included here) + | { 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 | { type: "move_item", from: ItemLocation, to: ItemLocation } // Item moved | { type: "set_item", location: ItemLocation, item?: ItemIndex } // the item contained in a tile or player changed | { type: "set_progress", item: ItemLocation, progress?: number, warn: boolean } // A tile is doing something. progress goes from 0 to 1, then null when finished @@ -58,7 +59,6 @@ export type PacketC = | { type: "server_message", text: string } // Text message from the server | { type: "score" } & Score // Supplies information for score OSD | { type: "menu" } & Menu // Open a menu on the client-side - | { type: "movement_sync" } // Your movement is difference on the server, you should update your position from a `position` packet | { type: "environment", effects: string[] } | { type: "set_ingame", state: boolean, lobby: boolean } // Set to false when entering the game or switching maps | { type: "error", message: string } // Your client did something wrong. |