diff options
Diffstat (limited to 'test-client/main.ts')
| -rw-r--r-- | test-client/main.ts | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/test-client/main.ts b/test-client/main.ts index f66a46a4..e106a135 100644 --- a/test-client/main.ts +++ b/test-client/main.ts @@ -96,7 +96,6 @@ export interface PlayerData extends MovementBase { id: number, name: string, hands: ItemSlot[], - direction: V2, class: PlayerClass, character: number, anim_position: V2, @@ -188,12 +187,13 @@ function packet(p: PacketC) { character: p.character.color, class: p.class, name: p.name, - rot: 0, + rotation: 0, facing: { x: 0, y: 1 }, - vel: { x: 0, y: 0 }, - direction: { x: 0, y: 0 }, + velocity: { x: 0, y: 0 }, stamina: 0, boosting: false, + input_boost: false, + input_direction: { x: 0, y: 0 }, }) break; } @@ -202,15 +202,13 @@ function packet(p: PacketC) { break; 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 - // TODO this is actually not a good idea if latency is too high - // if (p.player == my_id && dist < 3) return; // we know better where we are - if (p.player == my_id) return last_server_sent_position = pos - pl.position.x = pos.x - pl.position.y = pos.y - pl.boosting = p.boost - pl.rot = p.rot + if (p.player == my_id) return last_server_sent_position = { x: p.pos[0], y: p.pos[1] } + pl.position.x = p.pos[0] + pl.position.y = p.pos[1] + pl.rotation = p.rot + pl.input_direction.x = p.dir[0] + pl.input_direction.y = p.dir[1] + pl.input_boost = p.boost break; } case "move_item": { @@ -325,7 +323,7 @@ function packet(p: PacketC) { break; case "environment": break - case "effect": + case "effect2": break; case "flush_map": break; @@ -424,12 +422,12 @@ export function get_interact_target(): V2 | undefined { if (location.hash.search("oldinteract") != -1) return { - x: Math.floor(me.position.x + Math.sin(me.rot)), - y: Math.floor(me.position.y + Math.cos(me.rot)) + x: Math.floor(me.position.x + Math.sin(me.rotation)), + y: Math.floor(me.position.y + Math.cos(me.rotation)) } - const rx = me.position.x + Math.sin(me.rot) * 0.7 - const ry = me.position.y + Math.cos(me.rot) * 0.7 + const rx = me.position.x + Math.sin(me.rotation) * 0.7 + const ry = me.position.y + Math.cos(me.rotation) * 0.7 const bx = Math.floor(rx) const by = Math.floor(ry) let best = { x: bx, y: by } @@ -465,7 +463,7 @@ function set_interact(edge: boolean, hand: number) { 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], dir: [p.direction.x, p.direction.y], boost: p.boosting }) + send({ player: my_id, type: "movement", pos: [p.position.x, p.position.y], dir: [p.input_direction.x, p.input_direction.y], boost: p.boosting }) } function frame_update(dt: number) { @@ -479,8 +477,10 @@ function frame_update(dt: number) { y: (+keys_down.has(KEY_DOWN) - +keys_down.has(KEY_UP)) }) if (interacting) direction.x *= 0, direction.y *= 0 - p.direction = direction - update_movement(p, dt, direction, keys_down.has("KeyK")) + p.input_direction = direction + p.input_boost = keys_down.has("KeyK") + + players.forEach(p => update_movement(p, dt)) for (const [_, a] of players) for (const [_, b] of players) |