summaryrefslogtreecommitdiff
path: root/test-client/main.ts
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-06-18 10:17:40 +0200
committermetamuffin <metamuffin@disroot.org>2024-06-23 19:20:50 +0200
commit20a978e4f91e03588bf89d2426ee215f176b1ac7 (patch)
treeb99bd5b52dbd7cc31cec9bfcf79a197184f72a40 /test-client/main.ts
parent9bdb81bb34bd6a7e33c47d6fcb3dced1c5bda991 (diff)
downloadhurrycurry-20a978e4f91e03588bf89d2426ee215f176b1ac7.tar
hurrycurry-20a978e4f91e03588bf89d2426ee215f176b1ac7.tar.bz2
hurrycurry-20a978e4f91e03588bf89d2426ee215f176b1ac7.tar.zst
passive recipes work
Diffstat (limited to 'test-client/main.ts')
-rw-r--r--test-client/main.ts26
1 files changed, 17 insertions, 9 deletions
diff --git a/test-client/main.ts b/test-client/main.ts
index 3926dffc..ef84689f 100644
--- a/test-client/main.ts
+++ b/test-client/main.ts
@@ -1,7 +1,8 @@
/// <reference lib="dom" />
import { Gamedata, ItemID, ItemIndex, PacketC, PacketS, PlayerID, TileIndex } from "./protocol.ts";
-import { FALLBACK_TILE, TILES } from "./tiles.ts";
+import { FALLBACK_ITEM } from "./tiles.ts";
+import { FALLBACK_TILE, ITEMS, TILES } from "./tiles.ts";
import { V2, add_v2, ceil_v2, floor_v2, length, lerp_exp_v2_mut, normalize } from "./util.ts";
let ctx: CanvasRenderingContext2D;
@@ -192,15 +193,11 @@ function draw_ingame() {
for (const [_, tile] of tiles) {
ctx.save()
- ctx.translate(tile.x, tile.y)
+ ctx.translate(tile.x + 0.5, tile.y + 0.5)
const comps = TILES[data.tile_names[tile.kind]] ?? FALLBACK_TILE
for (const c of comps) {
c(ctx)
}
- if (tile.active_progress !== null && tile.active_progress !== undefined) {
- ctx.fillStyle = "rgba(115, 230, 58, 0.66)"
- ctx.fillRect(0, 0, 1, tile.active_progress)
- }
ctx.restore()
}
@@ -216,10 +213,21 @@ function draw_ingame() {
for (const [_, item] of items) {
ctx.save()
-
ctx.translate(item.x, item.y)
- ctx.fillStyle = "rgb(252, 19, 19)"
- ctx.fillRect(-0.1, -0.1, 0.2, 0.2)
+ const comps = ITEMS[data.item_names[item.kind]] ?? FALLBACK_ITEM
+ for (const c of comps) {
+ c(ctx)
+ }
+ ctx.restore()
+ }
+
+ for (const [_, tile] of tiles) {
+ ctx.save()
+ ctx.translate(tile.x, tile.y)
+ if (tile.active_progress !== null && tile.active_progress !== undefined) {
+ ctx.fillStyle = "rgba(115, 230, 58, 0.66)"
+ ctx.fillRect(0, 0, 1, tile.active_progress)
+ }
ctx.restore()
}