Hi Ant,
This post has to do with your original code, but depending on your goal, you might want to go with TDK's method.
The problem you were describing seems to lie in this part of your code:
`Move camera with mouse
if mouseclick() <> 1
text x,y,"Camera X Position : "+str$(mousex())
text x,y+10,"Camera Y Position : "+str$(mousey())
text x,y+20,"Camera Z Position : "+str$(mousez())
position camera mousex(),mousey(),mousez()
endif
The last line before endif is the culprit. When the button is released, you are telling the camera to position itself at whatever the current mouse coordinates are. They do not corespond to the 3d world coordinates so you have the camera jump to where ever the (invisible) mouse pointer has moved.
I modified your original code and changed that line so that the position of the camera is determined relative to itself, but it repositions based on the mouse movement. It's almost just like you had with just a couple of variables added. I also added WRAPVALUE() to your object rotation routine to keep the angle from exceeding 360. I don't have a mouse wheel so I don't know how that is affected, but it works without one. Oh yeah, you'll have to change your position text so that it matches the camera pposition instead of the mouse position.
hide mouse
sync on
sync rate 60
set text font "times new roman"
set text size 14
set text to bold
make matrix 1,1000,1000,20,20
make object sphere 1,10
position camera x#+500,y#+300,z#-600
position object 1,x+500,y+5,z
color backdrop 0
do
`Object Position text
ink rgb(0,0,255),0
text x+400,y,"Object X Position : "+str$(object position x(1))
text x+400,y+10,"Object Y Position : "+str$(object position y(1))
text x+400,y+20,"Object Z Position : "+str$(object position z(1))
`Bearing text
bearing=wrapvalue(object angle y(1))
text x+437,y+30," Bearing : "+str$(bearing)
`Direction text
ink rgb(255,0,0),0
text x,y+screen height()-20,direction$
````````set camera to follow object position x(1),object position y(1),object position z(1),object angle y(1),100,40,1,1
`Object sphere movement
if upkey()=1 then move object 1,4
if downkey()=1 then move object 1,-4
if leftkey()=1 then yrotate object 1,wrapvalue(object angle y(1)-1)
if rightkey()=1 then yrotate object 1,wrapvalue(object angle y(1)+1)
`Collision
if object position x(1) < 0 then position object 1,0,object position y(1),object position z(1)
if object position x(1) > 1000 then position object 1,1000,object position y(1),object position z(1)
if object position z(1) < 0 then position object 1,object position x(1),object position y(1),0
if object position z(1) > 1000 then position object 1,object position x(1),object position y(1),1000
`Bearing algorithm :-(
if bearing > 340 or bearing < 90
direction$="North"
endif
if bearing > 20
direction$="East"
endif
if bearing > 160
direction$="South"
endif
if bearing > 220
direction$="West"
endif
`***********************************************************************************************************************************************
`Move camera with mouse
rem let's get the cameras actual position coordinates
camx#=camera position x()
camy#=camera position y()
camz#=camera position z()
if mouseclick() <> 1
text x,y,"Camera X Position : "+str$(mousex())
text x,y+10,"Camera Y Position : "+str$(mousey())
text x,y+20,"Camera Z Position : "+str$(mousez())
rem use our camera position and the movement of the mouse to move the camera
position camera camx#+(1*mousemovex() ),camy#+(1*mousemovey() ),camz#+(1*mousemovez())
endif
if mouseclick()=1
ink rgb(0,255,0),0
text x,screen height()-80,"Camera X Position : "+str$(mousex())
text x,screen height()-70,"Camera Y Position : "+str$(mousey())
text x,screen height()-60,"Camera Z Position : "+str$(mousez())
move camera -1*mousemovey()
endif
`***********************************************************************************************************************************************
sync
loop
wait key
end
Enjoy your day.