ok thanks arras i see what you are saying.
and spooky i cant quite get pick object to work
here is the actual code. the pick object command only seems to work with one object on the screen, the plain over box one,you will see what i mean. am i useing it wrong, or what do the "object end" and "object start" arguements actually signify, distance or size?
`---------
` Types
`---------
type locationType
x as float
y as float
z as float
endtype
type cameraType
zoom as float
loc as locationType
old as float
new as float
endtype
type cameraAngleType
old as locationType
new as locationType
endtype
`-------------
` Variables
`-------------
dim level(400) as locationType
global center = 1000
global cam as cameraType
global maxCamDist = 1415
cam.loc.x = 1000-(sin(0)*1000)
cam.loc.y = 500
cam.loc.z = 1000-(cos(0)*1000)
global cameraAngle as cameraAngleType
`----------------
` Set up world
`----------------
set display mode 1024,768,32
Sync On
Sync Rate 120
autocam off
backdrop on
position mouse 300,200
position camera cam.loc.x,cam.loc.y,cam.loc.z
point camera 1000,100,1000
`--------------
` Make level
`--------------
makeLevel()
set image colorkey 255,128,255
`load image "box.bmp", 5
make object plain 5000,100,100
`texture object 5000, 5
color object 5000, RGB(255,0,0)
`# w t c f l f a
set object 5000,1,1,0,2,0,0,0
xrotate object 5000, 90
ghost object on 5000
`-------------
` Main loop
`-------------
do
set cursor 0,0
set text size 24
print "x: ",int(cam.loc.x)," y: ",int(cam.loc.y)," z: ",int(cam.loc.z)
print "camer angle x: ",int(cameraAngle.new.x)," camer angle y: ",int(cameraAngle.new.y)
print "distance from center x: ", abs(center-int(cam.loc.x))," y: ", abs(0-int(cam.loc.y))," z: ", abs(center-int(cam.loc.z))
print "on object: ",pick object (mousex(),mousey(),1,30)," mouse x: ",mousex()," mouse y:",mousey()
PRINT "fps: ",screen fps()
mouseOver()
moveCamera()
POINT OBJECT 30, cam.loc.x, 100, cam.loc.z
sync
loop
`-------------
` Functions
`-------------
function mouseOver()
r = 0
for i = 1 to 100
ox=OBJECT SCREEN X(i+1000)+((OBJECT SCREEN X(i+1000)-OBJECT SCREEN X (i+1000 + ((i+1000)<1100)))/2)
oy=OBJECT SCREEN Y(i+1000)+((OBJECT SCREEN y(i+1000)-OBJECT SCREEN y (i+1000 + ((i+1000)<1100)))/2)
if mousex()>=ox-50 and mousex()<=ox+50 and mousey()>=oy-50 and mousey()<=oy+50
r= i
break
endif
next i
position object 5000,level(r).x,level(r).y+51,level(r).z
print "object #: ",r," x: ",mousex()," y: ",mousey()
endfunction
function moveCamera()
`cameraAngle.old.y = cameraAngle.new.y
`cameraAngle.old.x = cameraAngle.new.x
`cameraAngle.new.y = cameraAngle.new.y
`cameraAngle.new.x = cameraAngle.new.x
Rem Control input for camera
`If Upkey()=1
` XTest# = Newxvalue(cam.loc.x,cameraAngle.new.y,10)
` ZTest# = Newzvalue(cam.loc.z,cameraAngle.new.y,10)
` If XTest#>0 and XTest#<1800 and ZTest#>0 and ZTest#<1800
` cam.loc.x=XTest#
` cam.loc.z=ZTest#
` Endif
`Endif
` If Downkey()=1
` XTest# = Newxvalue(cam.loc.x,Wrapvalue(cameraAngle.new.y-180),10)
` ZTest# = Newzvalue(cam.loc.z,Wrapvalue(cameraAngle.new.y-180),10)
` If XTest#>0 and XTest#<1800 and ZTest#>0 and ZTest#<1800
` cam.loc.x=XTest#
` cam.loc.z=ZTest#
` Endif
` Endif
if mouseclick()=2
position mouse mousex(),mousey()
cameraAngle.new.y = WrapValue(cameraAngle.new.y+MousemoveX()*0.3)
cameraAngle.new.x = WrapValue(cameraAngle.new.x+MousemoveY()*0.3)
if WrapValue(cameraAngle.new.x-90) < 270 then cameraAngle.new.x = 0
if cameraAngle.new.x > 22 then cameraAngle.new.x = 22
cameraAngle.old.y = cameraAngle.new.y
cameraAngle.old.x = cameraAngle.new.x
endif
`Yrotate camera CurveAngle(cameraAngle.new.y,cameraAngle.old.y,24)
point camera 1000,100,1000
Xrotate camera CurveAngle(cameraAngle.new.x,cameraAngle.old.x,5)
if leftkey() = 1
inc cam.new
cam.loc.x=1000-(sin(cam.new)*1000)
cam.loc.z=1000-(cos(cam.new)*1000)
endif
if rightkey() = 1
dec cam.new
cam.loc.x=1000-(sin(cam.new)*1000)
cam.loc.z=1000-(cos(cam.new)*1000)
endif
Position Camera cam.loc.x,cam.loc.y,cam.loc.z
endfunction
function makeLevel()
boxZ# = 550
boxX# = 550
`load image "stonetiles.bmp", 1
for i = 0 to 9
for j = 1 to 10
thisBox = (i*10)+j
make object cube thisBox+1000,100
position object thisBox+1000,boxX#,0,boxZ#
`texture object thisbox+1000, 1
level(thisBox).x = boxX#
level(thisBox).y = 0.0
level(thisBox).z = boxZ#
boxX# = boxX# + 100
next j
boxZ# = boxZ# + 100
boxX# = 550
next i
position object 1001,level(1).x,20,level(1).z
level(1).y = 20
`load image "1005.jpg", 2:`sky02.jpg
make object sphere 2000, 100
scale object 2000,3000,3000,3000
set object 2000,1,1,0,2,1,1,0
set object texture 2000,1,0
color object 2000,RGB(128,255,255)
texture object 2000,2
scale object texture 2000,3,3
position object 2000,1000,100,1000
`remstart
`set image colorkey 255,128,255
`load image "char01.bmp", 3
make object plain 30,100,200
`texture object 30, 3
position object 30,level(1).x,level(1).y+145,level(1).z
`# w t c f l f a
set object 30,1,1,0,2,0,0,0
`remend
endfunction
thanks for the feed back
las