Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Trouble with 2D graphics

Author
Message
Aith
22
Years of Service
User Offline
Joined: 21st Oct 2002
Location:
Posted: 29th Oct 2002 07:29
I've been working on making a menu system, by drawing boxes for the menus and buttons. It works just fine, until something 3D is created. Then I can't get the 2D to draw over the 3D scene. I even used the draw to front command. Can anyone help me out here? Thanks.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 29th Oct 2002 11:01
if u want 2d to stay on the screen all the time it has to be updated in the main loop always for it be present each displayed frame.



maybe u try something like this and instead of coloring the buttons place text on the screen in front of a color then grabbing a part of that into a texture location and texturing the button with text or images.



rem ------------------------------------------------------
rem 3D Button Functions by indi
rem
rem Button areas in the form of 3D Planes (plains)
rem DarkBasic Version 1.13 /Pro Patch2full
rem September 9 2002
rem ------------------------------------------------------
rem
rem
rem What does it Do???:
rem it automatically assigns a 3d plain as a button
rem it will also setup a mouse hot spot according
rem to the 3d button variables at the top of the code
rem
rem using these functions
rem
rem Make3D_btn(objnum,3d_btn_siz,3d_btn_x,3d_btn_y)
rem Place3Dbtn(objnum,X,Y)
rem Check3D_btn_(x1,x2,y1,y2,ms)
rem Delete3D_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 Make3D_btn(3d_btn_siz,3d_btn_x,3d_btn_y)
rem Check3D_btn_(x1,x2,y1,y2,ms)
rem Delete3D_btn(objnum)

rem Function by Thomas Christ
rem Place3Dbtn(Object,X,Y)
rem ------------------------------------------------------

sync rate 0
sync on
randomize timer()


rem use arrays instead of variables in this example

3d_btn_x = 320
3d_btn_y = 240
3d_btn_siz = 150
3dbx1 = 3d_btn_x - (3d_btn_siz/2)
3dby1 = 3d_btn_y - (3d_btn_siz/2)
3dbx2 = 3d_btn_x + (3d_btn_siz/2)
3dby2 = 3d_btn_y + (3d_btn_siz/2)



Make3D_btn(1,3d_btn_siz,3d_btn_x,3d_btn_y)


rem temp main loop
do

Check3D_btn(3dbx1,3dbx2,3dby1,3dby2)

rem Output Debug
center text 320,20,"---==== 3D 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$(3dbx1)
center text object screen x(1)-90,object screen y(1)-20,"y1 " +STR$(3dby1)
center text object screen x(1)+90,object screen y(1)+120,"x2 " +STR$(3dbx2)
center text object screen x(1)+90,object screen y(1)+140,"y2 " +STR$(3dby2)

rem safe exit
if inkey$()="q"
Delete3D_btn(1)
end
endif

sync
loop






rem ------------------------------------------------------
rem Make3D_btn(3d_btn_siz,3d_btn_x,3d_btn_y) Function By David Smith
rem ------------------------------------------------------

function Make3D_btn(objnum,3d_btn_siz,3d_btn_x,3d_btn_y)
make object plain objnum,3d_btn_siz,3d_btn_siz
lock object on objnum
Place3D_btn(objnum,3d_btn_x,3d_btn_y)
color object objnum,rgb(155,155,155)
endfunction


rem ------------------------------------------------------
rem Place3Dbtn(Object,X,Y) Function by Thomas Christ
rem ------------------------------------------------------

Function Place3D_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 Check3D_btn(x1,x2,y1,y2,ms) Function by David Smith
rem ------------------------------------------------------

Function Check3D_btn(3dbx1,3dbx2,3dby1,3dby2)

If mousex()>3dbx1 and mousex()<3dbx2 and mousey()>3dby1 and mousey()<3dby2 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()>3dbx1 and mousex()<3dbx2 and mousey()>3dby1 and mousey()<3dby2 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()>3dbx1 and mousex()<3dbx2 and mousey()>3dby1 and mousey()<3dby2 and mouseclick()=2
center text 320,460,"right mouse click"
y = wrapvalue(y+1)
rotate object 1,0,0,y
color object 1,rgb(55,255,255)
endif


If mousex()>3dbx1 and mousex()<3dbx2 and mousey()>3dby1 and mousey()<3dby2 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 Delete3D_btn(objnum) Function By David Smith
rem ------------------------------------------------------
function Delete3D_btn(objnum)
delete object objnum
endfunction




http://www.lunarpixel.com/ is my new site
Aith
22
Years of Service
User Offline
Joined: 21st Oct 2002
Location:
Posted: 29th Oct 2002 20:50
Hey, indi. Thanks. The 3D approach works quite well. I guess I'll have to go back and start over, but at least it'll be easier this time.

Thanks again.

Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 30th Oct 2002 00:37
Draw to front/Back, Cls, and Sync are all needed to be used in thr right way. I can get 2d and 3d to work fine together.

--Mouse
Aith
22
Years of Service
User Offline
Joined: 21st Oct 2002
Location:
Posted: 30th Oct 2002 07:26
Mouse, would you mind edjucating me on this a little bit? I'm having a hard time getting my mind around this stuff. I haven't done that much with 2D before.

Although, it might be better for me to just shut up and actually figure it out.

Well, either way, thanks.

Login to post a reply

Server time is: 2024-11-23 17:34:39
Your offset time is: 2024-11-23 17:34:39