Game Development Community

Moving several player objects simultaniously?

by Christopher Gu · in Torque Game Builder · 07/14/2005 (2:32 pm) · 1 replies

Hey guys,

Me again. Thanks to your responses in the previous thread, I now have a nice Move_to function to move my characters linearly across the screen.

Now I have to get 4 player objects moving simultaniously in this manner O_o

I have 4 regions on the screen, each of which is occupied with one character. With the single character I have now, I check using the mouse coordinates to determine whether or not I set this character in motion. Now, lets say that I have all 4 characters on the screen. I click in the first player's region to get him moving to a predetermined destination (he doesnt stop until he reaches the destination). How do I make it so that, a second later while the other player is still moving, I can move one of the other characters to their own destinations (determined in part by where the mouse is clicked)?

#1
07/14/2005 (4:11 pm)
You can divide the mouse coordinates to determine what region it's being clicked in. Ie:
%regionX = mFloor( %mousePosX / %regionWidth ); // Round the result down
%regionY = mFloor( %mousePosY / %regionHeight );

if ( %regionX == %regionY )
    echo( "Region "@ %regionX @" clicked." );
So now you can divide the screen into as many regions as you want. Just define %regionWidth and %regionHeight, and there you go. In your case, you'd make the region width/height half of your scene view width/height (50/37.5 if you use 100/75 view size).

That's a guess off the top of my head. It could be disasterously incorrect, though. :) If your harddrive gets deleted from this method, I disclaim all responsibility!