summaryrefslogtreecommitdiff
path: root/test-client/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test-client/main.ts')
-rw-r--r--test-client/main.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/test-client/main.ts b/test-client/main.ts
index cfda74b5..c2619f6e 100644
--- a/test-client/main.ts
+++ b/test-client/main.ts
@@ -100,6 +100,7 @@ export let data: Gamedata = { item_names: [], tile_names: [], spawn: [0, 0], til
export let my_id: PlayerID = -1
export const camera: V2 = { x: 0, y: 0 }
+export let camera_scale = 0.05;
export const interact_target_anim: V2 = { x: 0, y: 0 }
export let interact_possible_anim: number = 0
export let interact_active_anim: number = 0
@@ -118,14 +119,11 @@ function packet(p: PacketC) {
break;
case "add_player": {
players.set(p.id, {
- position: {
- x: p.position[0],
- y: p.position[1],
- },
+ position: { x: p.position[0], y: p.position[1], },
+ anim_position: { x: p.position[0], y: p.position[1] },
character: p.character,
name: p.name,
rot: 0,
- anim_position: { x: 0, y: 1 },
facing: { x: 0, y: 1 },
vel: { x: 0, y: 0 },
stamina: 0,
@@ -140,6 +138,7 @@ function packet(p: PacketC) {
const pl = players.get(p.player)!
const pos = { x: p.pos[0], y: p.pos[1] }
const dist = length(sub_v2(pl.position, pos));
+ // 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
pl.position.x = pos.x
pl.position.y = pos.y
@@ -301,6 +300,9 @@ function frame_update(dt: number) {
lerp_exp_v2_mut(interact_target_anim, it, dt * 15.)
interact_possible_anim = lerp_exp(interact_possible_anim, +possible, dt * 18.)
interact_active_anim = lerp_exp(interact_active_anim, +!!interacting, dt * 15.)
+
+ const zoom_target = Math.min(canvas.width, canvas.height) * (keys_down.has("KeyL") ? 0.05 : 0.1)
+ camera_scale = lerp_exp(camera_scale, zoom_target, dt * 5)
}
function resize() {