Author Topic: Pushing objects  (Read 2496 times)

0 Members and 1 Guest are viewing this topic.

Offline Andrew_Baker

Pushing objects
« on: March 08, 2002, 04:05:44 PM »
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.
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »


I hope you realize that one day I will devour the Earth.

Offline Andrew_Baker

Re: Pushing objects
« Reply #1 on: March 11, 2002, 01:18:59 PM »
add the following lines of code to the new.room initialization:

vxx = 2;
step.size(pushable_object, vxx);

The push object is now stick-free for all intents and purposes.  Not completely stick-free, but it won't glue itself to the ego the way it did in my original code.

PS.  Is there an AGI game that has done this before?
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »
I hope you realize that one day I will devour the Earth.

Offline Nick Sonneveld

Re: Pushing objects
« Reply #2 on: March 11, 2002, 01:31:28 PM »
The only thing I can think of is in the Donald Duck game when you're putting toys on the shelf.

- Nick
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »
Nick Sonneveld  |  AGI Dev  |  NAGI


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.05 seconds with 21 queries.