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 / Finding the distance between 2 points.. and are constants broken?

Author
Message
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 28th Apr 2003 20:34 Edited at: 28th Apr 2003 20:39
well that broke, lets try with code tags -_-

First up, distance finding ^_^ I'm out to make a function that can return the distance (as one value) between 2 points based on an x/z axis (as the terrain for my game is always flat, y is not important). So something like Get_Dist(x1, z1, x2, z2) - Any ideas? I can of course compare the two x's and z's, but i figured I would have to combine them into one value some how.. like to adverage them or something.. or perhaps will just adding them together work? like a = x1 + z1, b = x2 + y2... and then something like if a > b then return a - b else return b - a... im not sure, my head hurts whenever i think about it for some reason -_- Guess im not having a good day! but just to calrify it would be used in this kind of way:



this is for my ai routine to decide if a target is nearer ^^

About constants.. they dont seem to be working for me :/ Check this out:



That does not work.. but if i replace Case SHELL_TYPE with Case 1 then it DOES work.. -_- Also, pressing F1 on #constant causes the help system to error as it cant find the page *_* real annoying for me because i use constants ALOT in my programming :/

Anyone have any ideas about any of these two things? Thanks in advance for your time ^_^

(Sorry for broken first message, i hope the code tags fixed it)

Easily Confused
21
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 28th Apr 2003 21:07
This function will do the trick:



The constants are not broken, you need to drop the = sign, so:

#CONSTANT SHELL_TYPE = 1

becomes:

#CONSTANT SHELL_TYPE 1

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 28th Apr 2003 21:14
ahh! Thankyou so much! I really appreichate that ^_^

The Wendigo
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 29th Apr 2003 01:20
Oh! you need the blasted '#' hey? That might just help me, thx!

<<Insert signature here>

Login to post a reply

Server time is: 2024-09-20 05:36:03
Your offset time is: 2024-09-20 05:36:03