rem sync rate 24 to see the info more slowly
rem and to catch the error. You can increase it
rem or decrease it as you want :).
sync on:sync rate 24
load image "textures\grass.bmp",1
make matrix 1,5000,5000,20,20
prepare matrix texture 1,1,1,1
rem make player
make object cone 1,8
xrotate object 1,90
fix object pivot 1
position object 1,2500,500,2500
rem make dummy object
make object cone 2,2
xrotate object 2,90
fix object pivot 2
lock object on 2
position object 2,4.5,-4,10
rem for the chase camera
make object sphere 150,1
do
Chase_Cam2(1)
gosub Handle_Player
gosub Info_for_the_tester
sync
loop
function chase_cam2(id)
`work out the angle of the object being chased
rem yAng#=curveangle(object angle y(id),yAng#,10)
`grab the objects current position
xPos#=object position x(id)
yPos#=object position y(id)
zPos#=object position z(id)
`other variables
camDist=50
camHeight=8
`work out new position
xCamPos#=newxvalue(xPos#,yAng#,camDist)
zCamPos#=newzvalue(zPos#,yAng#,camDist)
xCamPos#=curvevalue(xCamPos#,object position x(id),8)
yCamPos#=curvevalue(yCamPos#,object position y(id),8)
zCamPos#=curvevalue(zCamPos#,object position z(id),8)
yCamPos#=object position y(id)+camheight
`update camera position
position camera xCamPos#,yCamPos#,zCamPos#
point camera xPos#,yPos#+camheight,zPos#
move camera 0+camDist
point camera xPos#,yPos#,zPos#
endfunction
Handle_Player:
playerx#=object position x(1)
playery#=object position y(1)
playerz#=object position z(1)
playerangx#=object angle x(1)
playerangy#=object angle y(1)
playerangz#=object angle z(1)
dummyangx#=object angle x(2)
dummyangy#=object angle y(2)
dummyangz#=object angle z(2)
rem player controls
if leftkey()=1 then fr#=fr#+4
if rightkey()=1 then fr#=fr#-4
if downkey()=1 then fu#=fu#+2
if upkey()=1 then fu#=fu#-2
` hat switch commands
if inkey$()="x" then turn object left 1, 1
if inkey$()="c" then turn object right 1, 1
rem rotation left/right variables
rem works like a curvevalue...
if fr#>0 then fr#=fr#-1
if fr#<0 then fr#=fr#+1
if fr#>=12 then fr#=12
if fr#<=-12 then fr#=-12
rem rotation up/down variables
rem work just like the left/right rotation variables
if fu#>0 then fu#=fu#-0.5
if fu#<0 then fu#=fu#+0.5
if fu#>8 then fu#=8
if fu#<-8 then fu#=-8
rem update player's rotation
roll object left 1,fr#/10
pitch object up 1, fu#/8
rem update dummy's orientation
set object to object orientation 2,1
rem speed
if inkey$()="a" then thrust#=thrust#+.50
if thrust#>10 then thrust#=10
if inkey$()="z" then thrust#=thrust#-.10
if thrust#<0 then thrust#=0
rem handle speed and move player
speed#=curvevalue(thrust#,speed#,25)
move object 1, speed#
rem playery#-40 because the player's plane is 40 units
rem up because of the wheels
altitude#=playery#-40
rem if the player hit the ground then don't make the
rem player pass it
if playery#<get ground height(1,playerx#,playerz#)+40
rem get player's height
playery#=get ground height(1,playerx#,playerz#)+40
rem put the player "in the ground"
position object 1,playerx#,playery#,playerz#
Problem:
rem **********************************************************
rem THIS IS WHERE THE REAL PROBLEM STARTS
rem try to maneuver in some way you can see the entire cone
rem and try to crash...you'll see that the rotation is screwed
rem up...
rem **********************************************************
xrotate object 1,0
endif
return
Info_for_the_tester:
set cursor 0,0
print "Cursor keys: move cone (F-16 *lol*)"
print "A/Z Accelerate / Brake"
print "X/C rotate the cone in the Y angle"
print "Player X = ",PlayerX#
print "Player Y = ",PlayerY#
print "Player Z = ",PlayerZ#
print "Player Angle X = ",PlayerAngX#
print "Player Angle Y = ",PlayerAngY#
print "Player Angle Z = ",PlayerAngZ#
print ""
print "--------DUMMY SECTION--------"
print ""
print "Dummy Angle X = ",DummyAngX#
print "Dummy Angle Y = ",DummyAngY#
print "Dummy Angle Z = ",DummyAngZ#
return
Please help me, I've been for more than 2 weeks with this problem and haven't found any way to solve it
edit: now it looks good! :D thanks neurokaotix! :D
[edited by - DARKGuy on March 5, 2004 4:20:33 PM]
Greetings!! can someone help me please? :)
Greetings!!!! :D
Some friends have told me of this great site and well..here I am . I'm making a flight simulator in DarkBASIC Enhanced v1.13, but even the moderators in the DarkBASIC forums haven't found any way to solve my problem ...so some friends there told me that in this forum perhaps someone more experienced can help me...
Well...my problem is this: I'm using a matrix for the ground, and i'm using the "turn object left" and "pitch object up" and "roll object left" instructions, but these instructions doesn't change the real angle of the player model...it's like if I rotate it in my 3D modeling program...so I'm using a dummy object to get the real angles...ok, I get the correct angles of the F-16 (the player's model)...but my problem starts when I want to "align the F-16 to the ground". When I use "Xrotate object 1,0" (1 = F-16, 0 = angle), it looks like the instruction resets also the Y and Z angles, so everything remains at 0...
What do I need to know is how to put the X angle at 0 WITHOUT putting the Z and Y angles to 0...take for example...like if you were landing...you can't land at angle 0 always...
Also, some friends at the DarkBASIC forums have tried to help me explaining some things and one of them gived me some code...but it wasn't somewhat related to my problem...what do I really need is code!, I don't work with explanations...
if you don't understand my problem here's a sample program that works exactly like my F-16 (I'm not putting the original program because it's TOO big, and this sample program doesn't need any external files, except for one grass texture...) :
delete the post you just made, go back to the original post and edit it. Use the [source ] [ /source] (no spaces). That formats code in a much better way and in a textbox.
ty.
MindEngine Development
http://medev.sourceforge.net
ty.
MindEngine Development
http://medev.sourceforge.net
I am not sure what you are asking... are you asking how to change the X angle but not the Y and Z angles...?
It sounds like the x rotate function creates a new matrix. If the function creates a matrix( and you can get access to it), then multiply it with what you already have(the matrix of your f16 model) instead of setting it. This should( I think...) preserve your current rotation values on the z and y axis.
I havn''t used DarkBasic in a very looong time so I could be way off in this.
I havn''t used DarkBasic in a very looong time so I could be way off in this.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement