implement basic box entering and exiting in entity movement.

This commit is contained in:
HyperOnion 2023-06-24 10:08:37 +02:00 committed by transoptimal
parent 68c93726f0
commit b2b4d9dced
2 changed files with 7 additions and 11 deletions

View File

@ -41,20 +41,16 @@ export function set_pos (entity, x, y) {
entity.y = y;
if (out_of_bounds(entity)) {
clamp_pos(entity);
/*
const could_exit = world.exit_box();
if (could_exit) {
set_player_pos(0, 0);
} else {
set_player_pos(previous_x, previous_y);
if (entity.box.parent) {
entity.box = entity.box.parent;
// TODO: exit from side of box.
}
return;
*/
clamp_pos(entity);
}
if (world.get_tile(entity.box, entity.x, entity.y)?.type === "box") {
// TODO
entity.box = world.get_tile(entity.box, entity.x, entity.y).box;
// TODO: enter at edge of box.
}
}

View File

@ -28,7 +28,7 @@ on_press("ArrowDown", _ => {
on_press(" ", _ => {
world.set_tile(player.box, player.x + 1, player.y, {
type: "box",
box: world.create_box(),
box: world.create_box(player.box),
});
});