Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / i need help with getting distance

Author
Message
Soy Cocktail
20
Years of Service
User Offline
Joined: 23rd Dec 2003
Location:
Posted: 10th Jun 2004 07:32 Edited at: 10th Jun 2004 08:22
I need a distance command to insert into my code to reposisition an object if the two objects are close, here is my code. I use darkbasic pro



i tried the get distance functions in the code base, but couldnt get them to work

EDIT
asked my brother and got it to work
my script is
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Jun 2004 09:34


"eureka" - Archimedes
Soy Cocktail
20
Years of Service
User Offline
Joined: 23rd Dec 2003
Location:
Posted: 10th Jun 2004 15:13
thx, but i cant get the functions to return a variable, then use it. i made a function

but then when i tell it to print dist# it prints 0. when i put the code in my main loop withought a function and replace obj and obj2 with 100 and 200 the same numbers i gave the function when i called it by using distance(100,200) it works and reports correct values when i tell it to print dist#
the code i put in my main loop replacing obj with 100 and obj2 with 200 is
Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 10th Jun 2004 19:04


or



You were probably either not using a float to store the returned value, or trying to access dist# from outside the loop, when you should have been using the returned value from the function.

Athelon XP 1600+/Radeon 9600 Pro/256 RAM
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Jun 2004 00:03
When a function returns a value, you can think of that function as like a variable itself.
dist# is a local variable to the function. Meaning that only the function itself knows that variable exists. A global variable is one that can be seen by all functions.

"eureka" - Archimedes

Login to post a reply

Server time is: 2024-09-22 12:33:15
Your offset time is: 2024-09-22 12:33:15