add player rotation display
This commit is contained in:
parent
bfb92c513d
commit
e502ca00de
3 changed files with 9 additions and 5 deletions
|
@ -26,7 +26,3 @@ export function display_parser() {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function char_parser() {
|
|
||||||
return z.string().length(1);
|
|
||||||
}
|
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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/"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue