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.

DarkBASIC Professional Discussion / Bad [b]Get Ground Height()[/b] values

Author
Message
xFUZZYx
22
Years of Service
User Offline
Joined: 27th Jan 2003
Location:
Posted: 2nd Feb 2003 09:56
Hi peoplez. Please tell me why this code gives weird ground heights.

sync on : sync rate 90
center text 320,240, "Loading Blast Compile..."
sleep 500
load image "doit.bmp", 1


Rem ***** Main Source File *****
dim gravity#(0) : gravity#(0)=0.1
`add gravity value
dim ySpeed#(4)

make matrix 1,5000,5000,100,100
randomize matrix 1,50
prepare matrix texture 1,1,1,1
update matrix 1
Rem Now, load the player.
player=1
`load object "sphere.3ds", player
make object sphere 1, 10
Rem TEXTURE THE STUPID PLAYER WHY WONT THIS WOIK?!
`scale object 1,10,10,10
position object 1,2500,100,2500
do
`auto
set camera to follow playerX,playerY,playerZ,0,30,playerY+15,4,1
color object 1,rgb(red,grn,blu)
oldX=playerX
oldY=playerY
oldZ=playerZ
playerX=object position x(1)
playerY=object position y(1)
playerz=object position z(1)
move object 1, player_speed
if player_speed > 25 then player_speed = player_speed - 1
if upkey()=0 and player_speed > 0 then player_speed = player_speed - 1
if red >253 then player_speed = player_speed - 5 : red = red - 100
rotate object 1,0,yRot,0
print "x:";
print playerX
print "y:";
print playerY
print "z:";
print playerZ
print get ground height(1,playerX,playerZ)

`interactive
if upkey()=1 then player_speed = player_speed + 1 : if red get ground height(1,playerX,playerZ)+5
position object 1,playerX,playerY-1,playerZ
endif

sync
loop

`end

plz help...
-THE FUZZ
haggisman
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 2nd Feb 2003 12:28
I dont think get ground height is giving bad values



Specs:- 1GHZ athlon, Radeon8500, 192mb ram, winxp
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Feb 2003 13:20
Too many people are reporting this for them to all be wrong.

What version/patch level of DBPro are you using?
haggisman
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 2nd Feb 2003 17:05
Did you even try his code IanM?

Specs:- 1GHZ athlon, Radeon8500, 192mb ram, winxp
Beta1
22
Years of Service
User Offline
Joined: 28th Dec 2002
Location:
Posted: 2nd Feb 2003 19:13
I have the problem isnt a bug with get ground height


Fuzzy - The problem is this bit. Theres a couple of errors in the first line. It would help A LOT if you arranged your code a little more neatly rather than having 2 IFs on the same line. OK problem 1, you need a THEN after the IF red bit.

Second problem, the GET GROUND HEIGHT returns a value, so you need to specify a variable to put it in eg height#=GET GROUND HEIGHT(blah,blah,blah)

I think this is more what you mean



I'm not entirely sure what you want to do with the ground height once youve got it but I guessed it was probably meant to be playery

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Feb 2003 19:20
I have to admit that I didn't *hangs head in shame*. But in my defence, a lot of people are reporting problems with matrix's.
Beta1
22
Years of Service
User Offline
Joined: 28th Dec 2002
Location:
Posted: 2nd Feb 2003 19:21
i should also point out you have tried to prepare a matrix texture without loading an image to make it from, your matrix has an enormous number of polygons and is likely to eat your framerate, and you dont need spaces in buts like X = A + B (X=A+B works fine and is easier on the eyes)

infact I cant make the rest of the code do anything other than produce a randomised matrix...

xFUZZYx
22
Years of Service
User Offline
Joined: 27th Jan 2003
Location:
Posted: 2nd Feb 2003 23:32
Yeah, the reason i'm not just putting the sphere at the ground height is that i want it to kinda leap off of it.

-THE FUZZ
xFUZZYx
22
Years of Service
User Offline
Joined: 27th Jan 2003
Location:
Posted: 2nd Feb 2003 23:35
Beta... There IS a THEN in the if red bit..

-THE FUZZ
xFUZZYx
22
Years of Service
User Offline
Joined: 27th Jan 2003
Location:
Posted: 2nd Feb 2003 23:44
hey, guess what happened now? darkbasic pro stopped compiling; whenever i compile anything it says: Command in DLL command-table unrecognised (MESSAGE BOX%S%MessageBoxPopup) ........

-THE FUZZ
Beta1
22
Years of Service
User Offline
Joined: 28th Dec 2002
Location:
Posted: 3rd Feb 2003 14:48
not in this bit there isnt

`interactive
if upkey()=1 then player_speed = player_speed + 1 : if red get ground height(1,playerX,playerZ)+5
position object 1,playerX,playerY-1,playerZ
endif

Its the second if statement "if red get ground height(....." thats missing its THEN

Beta1
22
Years of Service
User Offline
Joined: 28th Dec 2002
Location:
Posted: 3rd Feb 2003 14:49
...and a variable to put the ground height into

Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 3rd Feb 2003 23:29
I KNOW WHAT IT IS. When u get the ground height, u put an objects positions in right? Well, the positions from the TOP of the model so thats why ur getting wierd values. Its not from the bottom part of the model that the command is using. I had this problem with a demo of DBPro. I know about it now though

xxxpetratxxx
B. R. W
Andy Igoe
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 4th Feb 2003 02:03
Considering that the height fluctuation is only 1% as a relative to the area of your matrix you might experience more sucess by using real variables for player position.

However this is relative to your game and your camera view etc. etc. So I provide this fix for you incase the 'weird ground heights' are because the height does not seem to be smooth. Otherwise everything seems to have been covered already.



Pneumatic

Pneumatic of Xev@EQ
God made the world in 7 days, but we're still waiting for the patch.

Login to post a reply

Server time is: 2025-05-17 16:26:59
Your offset time is: 2025-05-17 16:26:59