Table of Contents
************************************************************************
//
// 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; //these first two are the push_object's center dimensions
block_y = 75;
block_xr = 85; //follows are the perimeter dimensions of the block.
block_yt = 65; //r is right, t is top, l is left, b is bottom.
block_xl = 65;
block_yb = 85;
animate.obj(o1); //this is the push block.
load.view(2);
set.view(o1,2);
position.v(o1,block_x,block_y);
draw(o1);
ignore.objs(o1);
obj_speed = 2; //and this is the code that makes sure the object is non-stick.
step.size(pushable_object, obj_speed);
}
get.posn(ego,ego_x,ego_y);
if (ego_x > block_xl && //Is the ego in the perimeter?
ego_y > block_yt &&
ego_x < block_xr &&
ego_y < block_yb) {
get.dir(ego, this_way); //Then I simply set the object's direction to the ego's.
set.dir(o1, this_way);
get.posn(o1,block_x, block_y); //Then I update the object's coordinates
block_xr = block_x; //and the perimeter as well.
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); //And when the ego stops or leaves the push object's perimeter, the object
} //stops.
if (said("look")) {
print("Except for the stone block, this is an empty room.");
}
return();
Page: [ 1 ]