diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-03 12:12:56 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-03 12:12:56 +0200 |
commit | e4d230666cfd86edfe8b0e549e0630f6d84fb5c1 (patch) | |
tree | ab909e2584834d5b472c6827e209fb5d6b3e700b /test-client/visual.ts | |
parent | af9c45741e82241fb137842d3609073ea57536ab (diff) | |
download | hurrycurry-e4d230666cfd86edfe8b0e549e0630f6d84fb5c1.tar hurrycurry-e4d230666cfd86edfe8b0e549e0630f6d84fb5c1.tar.bz2 hurrycurry-e4d230666cfd86edfe8b0e549e0630f6d84fb5c1.tar.zst |
nametags in testclient
Diffstat (limited to 'test-client/visual.ts')
-rw-r--r-- | test-client/visual.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test-client/visual.ts b/test-client/visual.ts index dd676435..2fbe9f78 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, global_message, interact_active_anim, interact_possible_anim, interact_target_anim, items_removed, keys_down, my_id, players, points, tiles, time_remaining } from "./main.ts"; +import { ItemData, MessageData, PlayerData, TileData, camera, camera_scale, canvas, ctx, data, demands_completed, demands_failed, get_interact_target, global_message, interact_active_anim, interact_possible_anim, interact_target_anim, items_removed, keys_down, my_id, nametag_scale_anim, players, points, tiles, time_remaining } 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"; @@ -134,6 +134,25 @@ function draw_player(player: PlayerData) { ctx.rotate(-player.rot) draw_character(player.character) ctx.restore() + + if (nametag_scale_anim > 0.01) { + ctx.save() + ctx.translate(player.anim_position.x, player.anim_position.y) + ctx.translate(0, -1) + ctx.textAlign = "center" + ctx.font = "10px sans-serif" + ctx.scale(nametag_scale_anim / camera_scale, nametag_scale_anim / camera_scale) + const w = ctx.measureText(player.name).width + 20 + ctx.fillStyle = "#fffa" + ctx.beginPath() + ctx.roundRect(-w / 2, -10, w, 20, 5) + ctx.fill() + ctx.fillStyle = "black" + ctx.textBaseline = "middle" + ctx.fillText(player.name, 0, 0) + ctx.restore() + } + if (player.item) draw_item(player.item) } |