diff options
Diffstat (limited to 'test-client/main.ts')
| -rw-r--r-- | test-client/main.ts | 26 | 
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()      }  |