Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
1 registered members (AndrewAMD), 599 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Size of entity #322266
05/05/10 16:45
05/05/10 16:45
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Hi, I have run into a problem when getting the size of an entity at runtime (code).

What I am trying to do:
I have some vehicles that spawn in a certain place one after the other. what I want to do is make them wait before moving till the new car "fits" behing the car in front of it.

In pseudocode it would be something like this:
Code:
action Car_Move (ENITY* Previos_Spawn)
{

   make me passable and invisible;

   var my_size = get_my_length(me); //get my size
   var preceding_size = get_my_length(Previous_Spawn); //get car in front size

   var Distance; //store distance

   while(1)
   {
      Distance = abs(my.x - Previous_Spawn.x); //calculate distance
      if(Distance > ((my_size.x / 2) + (preceding_size.x / 2))) //compare distance with vehicle sizes to see if I fit
      {
         make me visible;
         make me non-passable;
         my.x++; //move forward
      }
      wait(1);
   }
}



Does anyone know what I can use to make the function "get_my_length(ENTITY*)" ?
And how to use "my_size" and "preceding_size" in "action Car_Move(ENTITY*)" ?

I would apreciate any help or hints to achieve this


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: Size of entity [Re: Carlos3DGS] #322270
05/05/10 17:04
05/05/10 17:04
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Would this help...
Code:
var GetEntitySize(ENTITY* ent, char type)
{
	if(type=='x'){return ((ent.max_x - ent.min_x)/2);}
	if(type=='y'){return ((ent.max_y - ent.min_y)/2);}
	if(type=='z'){return ((ent.max_z - ent.min_z)/2);}
}


Just pass in the entity to measure and in which direction as a character...

GetEntitySize(mycar,'x') // get size in x direction.

You may want to use 'c_setminmax' on the entity so that the bounding box is the right size.

Re: Size of entity [Re: Carlos3DGS] #322271
05/05/10 17:07
05/05/10 17:07
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Code:
function my_length(ENTITY* ent)
{
	return ent->min_x - ent->max_x;
}



For the my_size and preceeding thing size I would recommend implementing a list. For a fast approach simply use two pointers.

Code:
ENTITY* preceeding;
ENTITY* current;

void next_car(ENTITY* car)
{
	// Check if there is enough space for the car here...
	preceeding = current;
	current = car;
}




Always learn from history, to be sure you make the same mistakes again...
Re: Size of entity [Re: Carlos3DGS] #322326
05/06/10 04:43
05/06/10 04:43
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Thankyou very much for your tips, you guys helped me out a lot!


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1