diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-29 16:10:07 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-29 16:10:07 +0200 |
commit | 58f4ab0b26948bec13ba853c90298271e472169f (patch) | |
tree | 9fa6e4443addf067310ff9ba868ec72b9e237637 /test-client | |
parent | b0042dce860406431f2e486112b14987c665f6a8 (diff) | |
download | hurrycurry-58f4ab0b26948bec13ba853c90298271e472169f.tar hurrycurry-58f4ab0b26948bec13ba853c90298271e472169f.tar.bz2 hurrycurry-58f4ab0b26948bec13ba853c90298271e472169f.tar.zst |
implement points
Diffstat (limited to 'test-client')
-rw-r--r-- | test-client/main.ts | 2 | ||||
-rw-r--r-- | test-client/protocol.ts | 2 | ||||
-rw-r--r-- | test-client/visual.ts | 8 |
3 files changed, 8 insertions, 4 deletions
diff --git a/test-client/main.ts b/test-client/main.ts index 4d1e9c53..72e88c90 100644 --- a/test-client/main.ts +++ b/test-client/main.ts @@ -99,6 +99,7 @@ export const items_removed = new Set<ItemData>() export let data: Gamedata = { item_names: [], tile_names: [], spawn: [0, 0], tile_collide: [], tile_interact: [] } export let my_id: PlayerID = -1 +export let points = 0 export let demands_completed = 0 export let demands_failed = 0 export const camera: V2 = { x: 0, y: 0 } @@ -197,6 +198,7 @@ function packet(p: PacketC) { case "score": demands_completed = p.demands_completed demands_failed = p.demands_failed + points = p.points break; case "error": console.warn(p.message) diff --git a/test-client/protocol.ts b/test-client/protocol.ts index ba6a630c..28ed6d11 100644 --- a/test-client/protocol.ts +++ b/test-client/protocol.ts @@ -48,7 +48,7 @@ export type PacketC = | { type: "set_active", tile: Vec2, progress?: number, warn: boolean } // A tile is doing something. progress goes from 0 to 1, then null when finished | { type: "update_map", tile: Vec2, kind: TileIndex | null, neighbors: [TileIndex | null] } // A map tile was changed | { type: "communicate", player: PlayerID, message?: Message } // A player wants to communicate something, message is null when cleared - | { type: "score", demands_failed: number, demands_completed: number, } // Supplies information for score OSD + | { type: "score", points: number, demands_failed: number, demands_completed: number, } // Supplies information for score OSD | { type: "set_ingame", state: boolean } // Set to false when entering the game or switching maps | { type: "error", message?: Message } // Your client did something wrong. diff --git a/test-client/visual.ts b/test-client/visual.ts index 1b4363e8..19866710 100644 --- a/test-client/visual.ts +++ b/test-client/visual.ts @@ -15,7 +15,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { ItemData, MessageData, PlayerData, TileData, camera, camera_scale, canvas, ctx, data, demands_completed, demands_failed, get_interact_target, interact_active_anim, interact_possible_anim, interact_target_anim, items_removed, keys_down, my_id, players, tiles } from "./main.ts"; +import { ItemData, MessageData, PlayerData, TileData, camera, camera_scale, canvas, ctx, data, demands_completed, demands_failed, get_interact_target, interact_active_anim, interact_possible_anim, interact_target_anim, items_removed, keys_down, my_id, players, points, tiles } from "./main.ts"; import { PLAYER_SIZE } from "./movement.ts"; import { FALLBACK_TILE, ITEMS, TILES, FALLBACK_ITEM } from "./tiles.ts"; import { V2, ceil_v2, floor_v2 } from "./util.ts"; @@ -77,9 +77,11 @@ export function draw_ingame() { ctx.fillStyle = "white" ctx.textAlign = "left" ctx.textBaseline = "bottom" + ctx.font = "30px sans-serif" + ctx.fillText(`Points: ${points}`, 10, canvas.height - 60) ctx.font = "20px sans-serif" - ctx.fillText(`Completed: ${demands_completed}`, 10, canvas.height - 10) - ctx.fillText(`Failed: ${demands_failed}`, 10, canvas.height - 30) + ctx.fillText(`Completed: ${demands_completed}`, 10, canvas.height - 30) + ctx.fillText(`Failed: ${demands_failed}`, 10, canvas.height - 10) if (keys_down.has("KeyP")) { draw_debug() |