Gamestudio Links
Zorro Links
Newest Posts
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, exile, flink, monarch), 1,558 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 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 | 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