Author Topic: Moving an object  (Read 1604 times)

0 Members and 1 Guest are viewing this topic.

Offline Corby

Moving an object
« 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!



Offline Sami Tervo

Re:Moving an object
« Reply #1 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
Apocalyptic Quest [ http://apocalypticquest.cjb.net ] No Mutants Allowed [ http://www.nma-fallout.com ] Batmud [ http://www.bat.org ]

Offline Corby

Re:Moving an object
« Reply #2 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?

Offline Andrew_Baker

Re:Moving an object
« Reply #3 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.  
I hope you realize that one day I will devour the Earth.

Offline Corby

Re:Moving an object
« Reply #4 on: April 26, 2002, 04:37:02 AM »
Thanks alot. That really helped!


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

Page created in 0.059 seconds with 22 queries.