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.

Code Snippets / Easy way to tell if your going Up hills or Down (can work with ANY lanscape)

Author
Message
Trev
21
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Canada, Ontario
Posted: 15th May 2005 09:48
Heres a little code i just worked up figured some people might find it useful... use it if you want... if you need help or want me to add something just post it here.



Trevor Somerville
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 17th May 2005 20:13
Not bad but you can do it quite a bit easier I think.

Trev
21
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Canada, Ontario
Posted: 17th May 2005 21:54
Yes you're probly right but if there is a better way I don't really see it... but if you want to submit a better way plz do.

Trevor Somerville
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 21st May 2005 05:20
I just made it to a function
You can use this function on just the matrix you wan't to No matter what shape it have.

Here it is:


In case you don't know how to use it then here's a quick example code :




Enjoy

Visit PanzerGames here
Trev
21
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Canada, Ontario
Posted: 21st May 2005 09:00
well that is useful but it dosen't tell you if you if you're going up or down hills on a lanscape....

Trevor Somerville
P Schnell
20
Years of Service
User Offline
Joined: 13th Feb 2005
Location:
Posted: 21st May 2005 10:00 Edited at: 21st May 2005 10:01
I'm not at my own computer, so this is untested, but try this:


The slope is positive going uphill, and negative going downhill. As a bonus, the slope is mathematically accurate:

y2-y1
------
x2-x1

forewardY-currentY
-------------------
1

Edit: Subscript tag doesn't work.

qwe
21
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 21st May 2005 10:25
dont most ppl use y# and oldy# or equivalent values? to see whether you are going up or down, just see if y# is > or < than oldy#
P Schnell
20
Years of Service
User Offline
Joined: 13th Feb 2005
Location:
Posted: 21st May 2005 11:35
That only works if you're moving, the newxvalue() and newzvalue() lets you determine if you are FACING uphil or downhill.

Login to post a reply

Server time is: 2025-05-16 03:43:56
Your offset time is: 2025-05-16 03:43:56