add player rotation display

This commit is contained in:
JOLIMAITRE Matthieu 2024-10-20 22:27:03 +02:00
parent bfb92c513d
commit e502ca00de
3 changed files with 9 additions and 5 deletions

View file

@ -26,7 +26,3 @@ export function display_parser() {
}), }),
}); });
} }
function char_parser() {
return z.string().length(1);
}

View file

@ -5,9 +5,14 @@ import { query_in_rect } from "./world.ts";
export class CompDisplay { export class CompDisplay {
display; display;
constructor(display: string) { constructor(display: string) {
this.display = display; this.display = display;
} }
update(display: string) {
this.display = display;
}
} }
export function sys_render_world(center: Vec2, size: Vec2) { export function sys_render_world(center: Vec2, size: Vec2) {

View file

@ -55,6 +55,9 @@ export class Session {
move(direction: Vec2) { move(direction: Vec2) {
const pos = this.entity.get_force(CompPos); const pos = this.entity.get_force(CompPos);
pos.move_collide(this.engine, direction); 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( entity.insert(
new CompPlayer(), new CompPlayer(),
new CompPos(entity, position), new CompPos(entity, position),
new CompDisplay("`/"), new CompDisplay("P/"),
) )
); );
}; };