Gamestudio Links
Zorro Links
Newest Posts
Purchase A8 full licence version
by ukgamer. 04/29/26 18:09
Z9 getting Error 058
by k_ivan. 04/25/26 19:13
ZorroGPT
by TipmyPip. 04/25/26 16:09
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 4,296 guests, and 26 spiders.
Key: Admin, Global Mod, Mod
Newest Members
ukgamer, valino, juergenwue, VladMak, Geir
19210 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
where is first handle ? #146008
08/05/07 18:17
08/05/07 18:17
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Huummmmmmmmm...

Is there a special reason why this code works for calculating the closest object to my but not recognizes the first one ?

I mean, closestSlotToMe is calculated allright, but when the closest one is the slotID 1, it doesnt work

The are 9 slots..

Code:


function getClosest_Slot()
{
var i;
var idist;

while ( i < 10)
{
if(slotsHandle[i])
{
you = ptr_for_handle(slotsHandle[i]);

if(you)
{
if(vec_dist(my.x,you.x) < idist)
{
closestSlotToMe = you;
}
idist = vec_dist(my.x,you.x);
}
}
i += 1;
}
return (idist);
}




Re: where is first handle ? [Re: demiGod] #146009
08/05/07 19:12
08/05/07 19:12
Joined: Jan 2007
Posts: 221
F
Fenriswolf Offline
Member
Fenriswolf  Offline
Member
F

Joined: Jan 2007
Posts: 221
Hi,

the local var 'idist' gets not initialized. You should initialize it with a very high value prior to the while loop (eg var idist = 999999;).
Otherwise the condition of 'if(vec_dist(my.x,you.x) < idist)' can't be fulfilled at the beginning. I think that's the problem.

Re: where is first handle ? [Re: Fenriswolf] #146010
08/05/07 19:23
08/05/07 19:23
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Hey Fenriswolf,

thanks for your reply, that´s exactly the problem i didnt figured out, it works now.
Cheers


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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