aboutsummaryrefslogtreecommitdiff
path: root/test-client/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test-client/main.ts')
-rw-r--r--test-client/main.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/test-client/main.ts b/test-client/main.ts
index a3d5d2f2..eeb9d9c0 100644
--- a/test-client/main.ts
+++ b/test-client/main.ts
@@ -1,7 +1,7 @@
/// <reference lib="dom" />
import { Gamedata, ItemIndex, Message, PacketC, PacketS, PlayerID, TileIndex } from "./protocol.ts";
-import { V2, add_v2, length, lerp_exp_v2_mut, normalize, aabb_circle_distance, sub_v2 } from "./util.ts";
+import { V2, add_v2, length, lerp_exp_v2_mut, normalize, aabb_circle_distance, sub_v2, lerp_exp } from "./util.ts";
import { draw_ingame, draw_wait } from "./visual.ts";
export const PLAYER_SIZE = 0.4;
@@ -67,12 +67,13 @@ export const players = new Map<PlayerID, PlayerData>()
export const tiles = new Map<string, TileData>()
export const items_removed = new Set<ItemData>()
-export let data: Gamedata = { item_names: [], tile_names: [], spawn: [0, 0] }
+export let data: Gamedata = { item_names: [], tile_names: [], spawn: [0, 0], tile_collide: [], tile_interact: [] }
let my_id: PlayerID = -1
export const camera: V2 = { x: 0, y: 0 }
export const interact_target_anim: V2 = { x: 0, y: 0 }
+export let interact_possible_anim: number = 0
let interacting: V2 | undefined;
function send(p: PacketS) { ws.send(JSON.stringify(p)) }
@@ -227,8 +228,12 @@ function frame_update(dt: number) {
}
remove.forEach(i => items_removed.delete(i))
- lerp_exp_v2_mut(interact_target_anim, get_interact_target() ?? { x: 0, y: 0 }, dt * 15.)
lerp_exp_v2_mut(camera, p, dt * 10.)
+
+ const it = get_interact_target() ?? { x: 0, y: 0 };
+ const possible = data.tile_interact[tiles.get([it.x, it.y].toString())?.kind ?? 0] ?? false
+ lerp_exp_v2_mut(interact_target_anim, it, dt * 15.)
+ interact_possible_anim = lerp_exp(interact_possible_anim, +possible, dt * 18.)
}
function resize() {