diff options
Diffstat (limited to 'test-client/pinned_messages.ts')
| -rw-r--r-- | test-client/pinned_messages.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test-client/pinned_messages.ts b/test-client/pinned_messages.ts new file mode 100644 index 00000000..e0ef47d7 --- /dev/null +++ b/test-client/pinned_messages.ts @@ -0,0 +1,48 @@ +/* + Hurry Curry! - a game about cooking + Copyright (C) 2026 Hurry Curry! Contributors + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, version 3 of the License only. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +*/ + +import { SPlayers } from "./map/players.ts"; +import { SSprites } from "./map/sprites.ts"; +import { System } from "./system.ts"; +import { lerp_exp_v2_mut } from "./util.ts"; + +export class SPinnedMessages extends System { + constructor( + public ss: SSprites, + public ps: SPlayers + ) { super() } + + override tick(dt: number): void { + let pin_xo = 0 + for (const [_, player] of this.ps.players) { + if (player.message_pinned && player.message_pinned.tick(dt)) delete player.message_pinned + if (player.message_pinned) lerp_exp_v2_mut(player.message_pinned.anim_position, { x: pin_xo++, y: 0 }, dt * 5) + } + } + override draw(ctx: CanvasRenderingContext2D): void { + const scale = Math.max(80, ctx.canvas.width / 20) + ctx.save() + ctx.scale(scale, scale) + ctx.translate(0.8, 0.8) + + for (const [_, player] of this.ps.players) + if (player.message_pinned) player.message_pinned.draw(ctx, this.ss, false) + + ctx.restore() + } +} |