hi,
i am making an (rpg) like red alert 2 but i am have somepobles with the mouse code. i need to click on a object in 3d space anywhere on the map. i have tryed very hard but still can not get it to work.
please help!!!!
here is my code
Rem Project: Dark exist
Rem Created: 30/03/2005 07:47:43
Rem Made By Simon Phillips
`set display mode 800,600,16
sync on
sync rate 1000
backcolor=rgb(25,0,0)
backdrop on
color backdrop backcolor
cls
`setting up varibles
scrollspeed=5
` Attention ... This value is the size of the map ! change it to fit your map file
mapsize=32
dim map$(mapsize,mapsize)
maxcubes=31
cubesize=100
collisionstep=int(cubesize/10)
` Current map
loadmap("media\maps\last life.dx",mapsize)
autocam off
`loading images for textureing
load image "floor.bmp",1
load image "zombie.bmp",2
load object "zombie.x",1
texture object 1,2
scale object 1,700,700,700
`floor
for i=1 to maxcubes*maxcubes
make object plain 1000+i,cubesize,cubesize
rotate object 1000+i,90,0,0
texture object 1000+i,1
next i
`setting lighting
set ambient light 50
make light 1
make light 2
set point light 1,0,0,0
set spot light 2,45,90
color light 2,RGB(252,216,141)
color light 1,RGB(236,182,100)
color light 0,RGB(0,0,0)
` Search startpoint
for z=1 to mapsize
for x=1 to mapsize
if map$(x,z)="O"
cx=x*cubesize
cz=z*cubesize
endif
if map$(x,z)="U"
ex=x
ez=z
endif
next x
next z
position camera cx,50,cz
position object 1,cx,(cubesize/2)*(-1),cz
pitch camera down 45
`the main do loop
do
`trying to click on object
if pick object(mousex(),mousey(),0,1000)=1
print "hit"
endif
`moveing cams from keya
if upkey()=1 then position camera camera position x(),camera position y(),camera position z()+scrollspeed
if downkey()=1 then position camera camera position x(),camera position y(),camera position z()-scrollspeed
if rightkey()=1 then position camera camera position x()+scrollspeed,camera position y(),camera position z()
if leftkey()=1 then position camera camera position x()-scrollspeed,camera position y(),camera position z()
if returnkey()=1 then end
`setting up readly for for loops
zzz=0
for zz=1 to maxcubes
for xx=1 to maxcubes
zzz=zzz+1
curposx=int(cx#)+xx
curposz=int(cz#)+zz
if curposx<=1 then curposx=1
if curposx>=mapsize then curposx=mapsize
if curposz<=1 then curposz=1
if curposz>=mapsize then curposz=mapsize
` floor
if map$(int(curposx),int(curposz))=":"
show object 1000+zzz
position object 1000+zzz,curposx*cubesize,(cubesize/2)*(-1),curposz*cubesize
else
hide object 1000+zzz
endif
next xx#
next yy#
`setting the lighting
position light 1,camera position x(),camera position y(),camera position z()
color light 1,RGB(200+int(rnd(50)-25),120,60)
rotate light 2,camera angle x(),camera angle y(),camera angle z()
`redoing the loop
sync
loop
`the map loading function
function loadmap(filename$,size)
open to read 1,filename$
for y=1 to size
for x=1 to size
read byte 1,tmp
map$(x,y)=chr$(tmp)
next x
next y
close file 1
endfunction
http://www.freewebs.com/dbpro/index.htm