i have a problem with some of my code, more specifically, the circlecam subroutine(just so you know where to look). The goal of this particular subroutine is to circle object 65535 while maintaining a distance of about 150. Turning to the right is no problem, but when you try to turn to the left, it will only turn untill the mouse hits the edge of the screen. Its kind of confusing to explain so here is my code. Sorry, its kind of messy because i am still trying different methods of almost every aspect of it.
`object number key
`1-200=enemies
`201-400=enemies sight
`401-600=enemies hearing
`601-800=non-moving objects
`801-1000=moving objects
`1001-3000=bullets
`3001-4000=special collisions and boundaries
`4001=herosound
`65535=hero
`65530-65534=landscape
`65500-65529=sky(moon,stars, etc)
`65498-65499=camera
rem loads the falling sound
load 3dsound "thump.wav",1
sync on
rem makes and sets up the landscape
make object plain 65530,400,400
make object plain 65531,400,400
xrotate object 65530,90
color object 65530,rgb(255,0,0)
xrotate object 65531,90
color object 65531,rgb(0,255,0)
position object 65531,object position x(65531),object position y(65531)-100,object position z(65531)+400
rem loads/creates and positions hero
make object box 65535,50,75,50
`color object 65535,0
position object 65535,object position x(65535),object position y(65535)+150,object position z(65535)
autocam off
rem makes camera positioning object and limb
make object sphere 65499,1
position object 65499,object position x(65535),object position y(65535),object position z(65535)
make mesh from object 1,65499
delete object 65499
add limb 65535,1,1
offset limb 65535,1,0,75,-150
hide limb 65535,1
make object sphere 65498,1
position object 65498,object position x(65535),object position y(65535),object position z(65535)
make mesh from object 2,65498
delete object 65498
add limb 65535,2,2
hide limb 65535,2
link limb 65535,1,2
rem positions the camera at the limbs position and points the camera at the
rem hero's x & z coords and at the limbs y coord.
position camera limb position x(65535,1),limb position y(65535,1),limb position z(65535,1)
point camera object position x(65535),object position y(65535),object position z(65535)
rem sets up camera distance variables
x4=0
y4=100
z4=150
rem main loop
do
gosub camvars
gosub keycontrol
text 0,0,str$(turny)
gosub gravity
gosub soundandfall
`text 50,0,str$(herovertvel)
if mousex<>mousex()
`1=left
`2=right
if mouse_x<mousex() then move=1
if mouse_x>mousex() then move=2
gosub circlecam
endif
for i=1 to 3
gosub camvars
gosub cammove
next i
point camera object position x(65535),object position y(65535)-50,object position z(65535)
position camera camera position x(),limb position y(65535,1),camera position z()
sync
mouse_x=mousex()
loop
end
camvars:
x1=camera position x()
x2=object position x(65535)
x3=x2-x1
z1=camera position z()
z2=object position z(65535)
z3=z2-z1
y1=camera position y()
y2=object position y(65535)
y3=y2-y1
xd=camera position x()-object position x(65535)
zd=camera position z()-object position z(65535)
distance=sqrt((xd*xd)+(zd*zd))
return
keycontrol:
`point camera object position x(65535),object position y(65535),object position z(65535)
if upkey()=1
move object 65535,5
` move camera 1.2
endif
if downkey()=1
move object 65535,-5
` if z4=z3
` move camera
` move camera -1
endif
if rightkey()=1
turn object right 65535,1
endif
if leftkey()=1
turn object left 65535,1
endif
if spacekey()=1
gosub jump
endif
` if upkey()=1 then move camera 1
` if downkey()=1 then move camera -1
` if rightkey()=1 then turn camera right 1
return
gravity:
collision=object collision(65535,0)
`65530 and 65531(down)
if collision=0
spothit=0
herovertvel=herovertvel-1
height=height+1
else
repeat
position object 65535,object position x(65535),object position y(65535)+1,object position z(65535)
until object collision(65535,0)=0
jump=0
position object 65535,object position x(65535),object position y(65535)-1,object position z(65535)
herovertvel=0
` position object 65535,object position x(65535),object position y(65535)+1,object position z(65535)
endif
return
soundandfall:
position object 65535,object position x(65535),object position y(65535)+herovertvel,object position z(65535)
if object collision(65535,0)<>0 and spothit=0
`play sound 1
spothit=1
make object sphere 4001,height*10
`hide object 4001
ghost object on 4001
position object 4001,object position x(65535),object position y(65535),object position z(65535)
play sound 1
if height>100
height=100
endif
set sound volume 1,height
set object 4001,1,1,1
set object 65535,1,1,0
ghost object on 65535
`wait key
delete object 4001
endif
return
circlecam:
turny=limb angle y(65535,2)+mousemovex()
if turny>360 then turny=turny-360
if turny<=0 then turny=turny+360
rotate limb 65535,2,0,turny,0
position camera limb position x(65535,1),limb position y(65535,1),limb position z(65535,1)
return
cammove:
` if distance>150
move camera distance-150
` endif
` if distance<150
` move camera distance-150
` endif
if y4<y3
` move camera y3-y4
position camera camera position x(),camera position y()+y3,camera position z()
endif
if y4>y3
` move camera y3-y4
position camera camera position x(),camera position y()+y3,camera position z()
endif
return
jump:
if jump=0
jump=1
herovertvel=20
repeat
position object 65535,object position x(65535),object position y(65535)+1,object position z(65535)
until object collision(65535,0)=0
endif
return