here is an old example of using 3d for sprites and buttons.
rem ------------------------------------------------------
rem D3 Button Functions by indi
rem
rem Button areas in the form of D3 Planes (plains)
rem DarkBasic Version 1.13
rem September 9 2002
rem ------------------------------------------------------
rem
rem
rem What does it Do???:
rem it automatically assigns a D3 plain as a button
rem it will also setup a mouse hot spot according
rem to the D3 button variables at the top of the code
rem
rem using these functions
rem
rem MakeD3_btn(objnum,D3_btn_siz,D3_btn_x,D3_btn_y)
rem PlaceD3btn(objnum,X,Y)
rem CheckD3_btn_(x1,x2,y1,y2,ms)
rem DeleteD3_btn(objnum)
rem
rem easy to adapt for multiple buttons
rem
rem *** The Rotation and colouring
rem *** are just to show its usage
rem
rem What doesn't it Do???
rem It wont change its hotspot size if u wish to change the button
rem size dynamically in your project.
rem
rem
rem
rem
rem Functions By David Smith
rem MakeD3_btn(D3_btn_siz,D3_btn_x,D3_btn_y)
rem CheckD3_btn_(x1,x2,y1,y2,ms)
rem DeleteD3_btn(objnum)
rem Function by Thomas Christ
rem PlaceD3btn(Object,X,Y)
rem ------------------------------------------------------
sync rate 0
sync on
randomize timer()
rem use arrays instead of variables in this example
D3_btn_x = 320
D3_btn_y = 240
D3_btn_siz = 150
D3bx1 = D3_btn_x - (D3_btn_siz/2)
D3by1 = D3_btn_y - (D3_btn_siz/2)
D3bx2 = D3_btn_x + (D3_btn_siz/2)
D3by2 = D3_btn_y + (D3_btn_siz/2)
MakeD3_btn(1,D3_btn_siz,D3_btn_x,D3_btn_y)
rem temp main loop
do
CheckD3_btn(D3bx1,D3bx2,D3by1,D3by2)
rem Output Debug
center text 320,20,"---==== D3 Buttons by indi ====---"
center text 320,40,"use mouse over square on screen"
center text 320,60,"mouse x "+STR$(mousex())
center text 320,80,"mouse y "+STR$(mousey())
center text object screen x(1)-90,object screen y(1)-40,"x1 " +STR$(D3bx1)
center text object screen x(1)-90,object screen y(1)-20,"y1 " +STR$(D3by1)
center text object screen x(1)+90,object screen y(1)+120,"x2 " +STR$(D3bx2)
center text object screen x(1)+90,object screen y(1)+140,"y2 " +STR$(D3by2)
rem safe exit
if inkey$()="q"
DeleteD3_btn(1)
end
endif
sync
loop
rem ------------------------------------------------------
rem MakeD3_btn(D3_btn_siz,D3_btn_x,D3_btn_y) Function By David Smith
rem ------------------------------------------------------
function MakeD3_btn(objnum,D3_btn_siz,D3_btn_x,D3_btn_y)
make object plain objnum,D3_btn_siz,D3_btn_siz
lock object on objnum
PlaceD3_btn(objnum,D3_btn_x,D3_btn_y)
color object objnum,rgb(155,155,155)
endfunction
rem ------------------------------------------------------
rem PlaceD3btn(Object,X,Y) Function by Thomas Christ
rem ------------------------------------------------------
Function PlaceD3_btn(objnum,X,Y)
Width = Screen Width()/2
Height = Screen Height()/2
Z# = Screen Height()*0.83
Position Object objnum,(X-Width),(Height-Y),Z#
EndFunction
rem ------------------------------------------------------
rem CheckD3_btn(x1,x2,y1,y2,ms) Function by David Smith
rem ------------------------------------------------------
Function CheckD3_btn(D3bx1,D3bx2,D3by1,D3by2)
If mousex()>D3bx1 and mousex()<D3bx2 and mousey()>D3by1 and mousey()<D3by2 and mouseclick()=0
center text 320,460,"mouse over"
color object 1,rgb(55,155,55)
else
color object 1,rgb(155,155,155)
endif
If mousex()>D3bx1 and mousex()<D3bx2 and mousey()>D3by1 and mousey()<D3by2 and mouseclick()=1
center text 320,460,"left mouse click"
y = wrapvalue(y+1)
rotate object 1,0,y,0
color object 1,rgb(55,255,55)
endif
If mousex()>D3bx1 and mousex()<D3bx2 and mousey()>D3by1 and mousey()<D3by2 and mouseclick()=2
center text 320,460,"right mouse click"
y = wrapvalue(y+45)
rotate object 1,0,0,y
color object 1,rgb(55,255,255)
endif
If mousex()>D3bx1 and mousex()<D3bx2 and mousey()>D3by1 and mousey()<D3by2 and mouseclick()=3
center text 320,460,"both buttons"
y = wrapvalue(y+1)
rotate object 1,y,y,y
color object 1,rgb(rnd(255),rnd(255),rnd(255))
endif
Endfunction
rem ------------------------------------------------------
rem DeleteD3_btn(objnum) Function By David Smith
rem ------------------------------------------------------
function DeleteD3_btn(objnum)
delete object objnum
endfunction
