I was thinking about having a ladder in a room in a game that I could move around and then climb. I thought all day about how I would accomplish this when I figured out this much. The view in question (o1) is 10 x 20, as is the ego. This produces a movable character that will push the block in the same direction he is going. The block is also sticky sometimes, so anyone who can figure out how to make it stick-free would be well-thanked.// ****************************************************************************
//
// Logic 2: Push block
//
// ****************************************************************************
#include "defines.txt"
if (new_room) {
load.pic(room_no);
draw.pic(room_no);
discard.pic(room_no);
set.horizon(37);
if ((prev_room_no == 1 ||
prev_room_no == 0)) {
position(ego,120,100);
status.line.on();
accept.input();
}
draw(ego);
show.pic();
block_x = 75;
block_y = 75;
block_xr = 85;
block_yt = 65;
block_xl = 65;
block_yb = 85;
animate.obj(o1);
load.view(2);
set.view(o1,2);
position.v(o1,block_x,block_y);
draw(o1);
ignore.objs(o1);
}
get.posn(ego,ego_x,ego_y);
if (ego_x > block_xl && //slightly sticky box
ego_y > block_yt &&
ego_x < block_xr &&
ego_y < block_yb) {
get.dir(ego,v53);
set.dir(o1,v53);
get.posn(o1,block_x,block_y);
block_xr = block_x;
block_xr += 10;
block_yt = block_y;
block_yt -= 10;
block_xl = block_x;
block_xl -= 10;
block_yb = block_y;
block_yb += 10;
}
else {
stop.motion(o1);
}
if (said("look")) {
print("Except for the stone block, this is an empty room.");
}
return();
I hope no one has already posted this code, and any suggestions on how to make it better will be appreciated.