diff --git a/common/message/to_client.ts b/common/message/to_client.ts index 46081c8..d63b402 100644 --- a/common/message/to_client.ts +++ b/common/message/to_client.ts @@ -26,7 +26,3 @@ export function display_parser() { }), }); } - -function char_parser() { - return z.string().length(1); -} diff --git a/server/components/display.ts b/server/components/display.ts index 4eebf70..dad1cef 100644 --- a/server/components/display.ts +++ b/server/components/display.ts @@ -5,9 +5,14 @@ import { query_in_rect } from "./world.ts"; export class CompDisplay { display; + constructor(display: string) { this.display = display; } + + update(display: string) { + this.display = display; + } } export function sys_render_world(center: Vec2, size: Vec2) { diff --git a/server/entities/player.ts b/server/entities/player.ts index f57a6f8..431e393 100644 --- a/server/entities/player.ts +++ b/server/entities/player.ts @@ -55,6 +55,9 @@ export class Session { move(direction: Vec2) { const pos = this.entity.get_force(CompPos); pos.move_collide(this.engine, direction); + const display = this.entity.get_force(CompDisplay); + if (direction.x() > 0) display.update("P/"); + if (direction.x() < 0) display.update("\\P"); } } @@ -64,7 +67,7 @@ export function sys_spawn_player(position: Vec2) { entity.insert( new CompPlayer(), new CompPos(entity, position), - new CompDisplay("`/"), + new CompDisplay("P/"), ) ); };