Well, I'm trying to make some sort of space game by using a sort of asteroids ship movements. And I have some problems with making my ship tilt a bit inwards when turning. Any suggestions on how to make it? btw I'm using ESC_'s vector tutorial.
Sync on
Sync rate 60
Backdrop on
Set display mode 1024,768,32
Set ambient light 70
make matrix 1,5000,5000,50,50
rem Object loading
load image "Data\Models\Crafts\2\skin.tga",1
load object "Data\Models\Crafts\2\cr2.x",1
texture object 1,1
scale object 1,15,15,15
load object "Data\Models\Stations\1\station1.x",2
load image "Data\Models\Stations\1\skin.tga",2
texture object 2,2
scale object 2,50,50,50
accel#=0.02
friction#=1.005
turnrate#=2
type vector
x as float
z as float
endtype
`set up the ship's main vector
shipv as vector
shipv.x=0
shipv.z=0
`setup component vector for vector addition
comv as vector
comv.x=0
comv.z=0
rem Ship Inits
shipx# = object position x(1)
shipy# = object position y(1)+75
shipz# = object position z(1)
xrotate camera 90
do
set cursor 0,0
print screen fps()
position camera x#,shipy#,z#
`rotate the ship
if keystate(32)=1
angle#=angle#+turnrate#
endif
if keystate(30)=1
angle#=angle#-turnrate#
endif
angle#=wrapvalue(angle#)
yrotate object 1,wrapvalue(1*(angle#))
`calculate the component vector (added to the main vector if upkey is pressed)
comv.x=sin(angle#)*accel#
comv.z=cos(angle#)*accel#
`ship movement
if keystate(17)=1
`add the vectors together to produce a final vector
shipv.x=shipv.x+comv.x
shipv.z=shipv.z+comv.z
endif
if keystate(31)=1
shipv.x = shipv.x - comv.x * 0.1
shipv.z = shipv.z - comv.z * 0.1
endif
`calculate friction
shipv.x=shipv.x/friction#
shipv.z=shipv.z/friction#
`reposition the ship
x#=x#+shipv.x
z#=z#+shipv.z
shipx# = x# + shipv.x
shipz# = z# + shipv.z
position object 1,x#,y#,z#
rem Camera controls
if shiftkey()= 1 and upkey()=1 and shipy# > 15
shipy# = shipy# - 1
endif
if shiftkey()=1 and downkey()=1 and shipy# < 150
shipy# = shipy# + 1
endif
sync
loop