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 / Matrix slope help please?

Author
Message
Rellik
21
Years of Service
User Offline
Joined: 8th Jun 2003
Location: United States
Posted: 9th Jun 2003 06:51
Hi, I'd consider myself a newbie to DarkBasic, and right now I'm working on mostly a test project (no models, just cubes and squares and stuff, just to learn and make my first relatively advanced game as opposed to the little tests I did before). It works on a vector system, (as in, with inertia, and when you move you're controlling acceleration, not actual movement), and I'm glad my trigonometry skills finally have come in handy . So yeah, it's a 3-d game, and I want to add a height dimension to it.

The problem is, though, that I don't know how to make it so that, depending on the slope of section of the matrix you are on currently, gravity is either with you or against you as you try to go up or down a slope, and in both x and z dimensions. Is there a function or something I could use to determine matrix slope at a particular point? I can try to figure out the rest from there, once I know how to get the actual value, even though it's kind of like one big math problem . But I really don't know how to get that value at all.

Thanks, if you could help. I like to work out programming stuff myself just for the challenge and learning, but in cases like this, I really need some guidance.
Rellik
21
Years of Service
User Offline
Joined: 8th Jun 2003
Location: United States
Posted: 10th Jun 2003 00:57
Oh, and by the way, I'm using DBPro. And I really would appreciate a reply.
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 10th Jun 2003 01:17 Edited at: 10th Jun 2003 01:17
You must find the height of the points in a matrix to find its slope. Like this

..........A
........./.\
........B--C

Theres an example of a poly making up a side of a hill on a matrix. You have to find the height in the middle of B & C, then find out the difference between that points height and the height of point A. With that, you can mathematically calculate (using possible a FOR NEXT opperation) how your speed will be effected by the slope of the hill. There was somewhat of an example of this in the Dark Basic tutorials (in the Newcomers Corner) for that game it demonstrates.

Cheers,

RPGamer

Current Project: Eternal Destiny
Questions? Comments? Suggestions? Go to the Eternal Destiny Forum!
Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 10th Jun 2003 02:34
check ground height at some point in front of you and behind you:
subtract front from back value if positive you're climbing if negative you are descending, you could relate your struggle (speed slow down or increase) according to the magnitude of the result.

ahead of you :
ax#=newxvalue(x#,angle#,+100)
az#=newzvalue(z#,angle#,+100
ay#=get ground height(matrixnumber,ax#,az#)
behind:
bx#=newxvalue(x#,angle#,-100)
bz#=newzvalue(z#,angle#,-100
by#=get ground height(matrixnumber,bx#,bz#)

legend= x# and z#: your (or your object ) x# and z# positions
angle#: your ( or your object ) angle
100 and -100 :ahead and behind values (can be changed)
ay# and by# heights straight ahead and behind you
Then:

slope#=ay#-by#

if slope#>0 then ..decrease speed# (see below)
if slope#<0 then ..increase speed# (see below)

you could relate speed to slope with something like:

speed#=speed#+abs(slope#) if descending and
speed#=speed#-abs(slope#) if climbing

hope it helps
cheers

Login to post a reply

Server time is: 2024-11-10 09:47:32
Your offset time is: 2024-11-10 09:47:32