Gamestudio Links
Zorro Links
Newest Posts
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
Zorro version 3.0 prerelease!
by TipmyPip. 02/24/26 17:09
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (Martin_HH, TipmyPip, AndrewAMD, Grant, USER0328), 5,287 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 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