diff options
Diffstat (limited to 'test-client/main.ts')
-rw-r--r-- | test-client/main.ts | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/test-client/main.ts b/test-client/main.ts index b2deeca5..8eab832d 100644 --- a/test-client/main.ts +++ b/test-client/main.ts @@ -20,7 +20,7 @@ import { init_locale } from "./locale.ts"; import { MovementBase, collide_player_player, update_movement } from "./movement.ts"; import { particle_splash, tick_particles } from "./particles.ts"; -import { Gamedata, ItemIndex, ItemLocation, Message, MessageTimeout, PacketC, PacketS, PlayerID, TileIndex } from "./protocol.ts"; +import { Gamedata, ItemIndex, ItemLocation, Message, MessageTimeout, PacketC, PacketS, PlayerID, Score, TileIndex } from "./protocol.ts"; import { V2, lerp_exp_v2_mut, normalize, lerp_exp } from "./util.ts"; import { draw_ingame, draw_wait } from "./visual.ts"; @@ -32,7 +32,7 @@ const KEY_LEFT = "KeyA" const KEY_RIGHT = "KeyD" const KEY_CHAT = "Enter" const KEY_CLOSE = "Escape" -const HANDLED_KEYS = [KEY_BOOST, KEY_CHAT, KEY_CLOSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT] +const HANDLED_KEYS = [KEY_INTERACT, KEY_BOOST, KEY_CHAT, KEY_CLOSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT] export let ctx: CanvasRenderingContext2D; export let canvas: HTMLCanvasElement; @@ -111,12 +111,9 @@ export const server_hints = new Map<string, MessageData>() export let data: Gamedata = { item_names: [], tile_names: [], spawn: [0, 0], tile_collide: [], tile_interact: [], maps: [] } -export let time_remaining: number | null = null export let global_message: MessageData | undefined = undefined export let my_id: PlayerID = -1 -export let points = 0 -export let demands_completed = 0 -export let demands_failed = 0 +export const score: Score = { active_recipes: 0, demands_completed: 0, demands_failed: 0, instant_recipes: 0, passive_recipes: 0, players: 0, points: 0, stars: 0, time_remaining: 0 } export const camera: V2 = { x: 0, y: 0 } export let camera_scale = 0.05; export const interact_target_anim: V2 = { x: 0, y: 0 } @@ -233,10 +230,10 @@ function packet(p: PacketC) { break; } case "score": - demands_completed = p.demands_completed - demands_failed = p.demands_failed - points = p.points - time_remaining = p.time_remaining ?? null + score.demands_completed = p.demands_completed + score.demands_failed = p.demands_failed + score.points = p.points + score.time_remaining = p.time_remaining ?? null break; case "error": global_message = { inner: { text: p.message }, anim_size: 0., anim_position: { x: 0, y: 0 }, timeout: { initial: 5, remaining: 5 } } @@ -342,7 +339,7 @@ function frame_update(dt: number) { const p = players.get(my_id) if (!p) return - if (time_remaining != null) time_remaining -= dt + score.time_remaining -= dt const direction = normalize({ x: (+keys_down.has(KEY_RIGHT) - +keys_down.has(KEY_LEFT)), |