implement basic box entering and exiting in entity movement.
This commit is contained in:
parent
68c93726f0
commit
b2b4d9dced
|
@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue