Community

AGI Programming => Mega Tokyo AGI Archive => Topic started by: Corby on April 23, 2002, 01:50:44 AM

Title: Moving an object
Post by: Corby on April 23, 2002, 01:50:44 AM
Hello, I'm sorry if this sounds really dumb but I need to know how to do one simple thing. I'm almost done my game but I need this one thing. I have a view (a car) and I want it to move from the left side of the screen to the right side. Can someone tell me everything I have to do? I spent a whole day trying to do this with no luck.
This is what I've tried:
define object
animate.obj
load.view
set.view
position
draw
start.cycling
move.obj
but it doesn't move! Do I have to use set.dir or something? I have basically no programming skills! Help!
Title: Re:Moving an object
Post by: Sami Tervo on April 23, 2002, 03:49:28 AM
here's example that should work:

 animate.obj(o10);
 load.view(10);
 set.view(o10,10);
 position(o10,5,100);
 draw(o10);
 move.obj(o10,145,100,2,f255);

if that won't work, check out example at:
http://koti.mbnet.fi/sterv/car.zip
Title: Re:Moving an object
Post by: Corby on April 23, 2002, 03:39:00 PM
Wow! That was easy! Thanks! Here's another easy problem:
I have two doors. How can I differentiate between the two so my character can walk to one individually and open it?
Title: Re:Moving an object
Post by: Andrew_Baker on April 23, 2002, 06:14:57 PM
I'm going to assume that you want to have the ego move to the door?

This isn't really much of a move object problem, but here's an example with some movement code.

Let's assume that one door is on the left side of the screen, and the other is on the right.  If your character is on the left-hand side, we'll have him open the left door.  If he is on the right-hand side, we'll have him open the right door.  So:

if (said("open","door")) { left door
   if (new_ego_x < 80) {
       program.control();
       move.obj(ego,x,y,stepsize,doneflag);
                if (doneflag) {
                    end.of.loop(oLEFTDOOR,anotherdoneflag);
                    //Above should animate door opening
                    player.control();
                    set(left_door_open);
                    }
        }
   if (new_ego_x > 80) {
         program.control();
         move.obj(ego,x,y,stepsize,doneflag);
                if (doneflag) {
                    end.of.loopoRIGHTDOOR,anotherdoneflag);
                    player.control();
                    set(right_door_open);
                    }
          }
}


I left the variables open, since I have no idea where your doors are going to be, but that should give you something to chew on.  
Title: Re:Moving an object
Post by: Corby on April 26, 2002, 04:37:02 AM
Thanks alot. That really helped!