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.

DarkBASIC Discussion / Screen buttons for 3-D game

Author
Message
HenryTj
20
Years of Service
User Offline
Joined: 2nd Nov 2005
Location:
Posted: 3rd Jul 2006 15:34
Im working on a 3D demo game for a tutorial. Is there an easy way to make screen buttons (for use with the mouse) in DBC? I read somewhere that it is bad to mix 2D and 3D features.

Thanks,
Henry
flock
20
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 3rd Jul 2006 16:13 Edited at: 3rd Jul 2006 16:14
I've done this before but I don't have the code. Make a box, have a certain (lets say blue) skin on it, then position it in some corner of the screen. Next, you need to print the mousex() and mousey() variables so you know the parameters of your input (the edges of the box). Now you write an if statement that says something like:

if mousex()>100 and mousey()>100 and mousex()<150 and mousey()<150
Texture Object whatever, other color
If mouseclick() = 1 then gosub endGame
Else
Texture Object whatever, old color
Endif


Hope that helps, I'm sure there's a better way but it definetly works well.

a.k.a. "flockhound"
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Jul 2006 16:51
Quote: "I read somewhere that it is bad to mix 2D and 3D features.
"


That is only true if you mean conversion between the two. And even then it is possible (but very very hard).

You can display 2D and 3D easily at the same time.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 3rd Jul 2006 17:15 Edited at: 3rd Jul 2006 17:16
You put the buttons on a 3D plain which is textured with buttons, or a GUI. It looks the same as 2D buttons, but is actually 3D. Then Lock Object On....

Which locks the buttons to the screen, meaning that the buttons move around with the camera.

HenryTj
20
Years of Service
User Offline
Joined: 2nd Nov 2005
Location:
Posted: 3rd Jul 2006 21:51
Thanks everyone. I had considered trying a 3D plane. My view moves through space so I guess I would have to track all the interface items with me. I had wanted to do something that sorta looked like a heads-up display. Maybe not possible with DBC. I tried "locking" a plane on the screen, but that seemed to turn the plane edge-wise to my camera.


Is there any alpha-transparency in DBC or just on/off with black? I tried ghosting the object. Thank might work okay. I already have a translucent grid seems to work okay, but its not clickable.

Thing is that I need to have this tutorial ready for a class in 10 days and its not the only thing I am working on. If it wasn't for the time pressure I would simply do alot of experimenting myself and not bothering others here. So, sorry about that.

Also I need a small "radar" like item on the display. The game action is happening in 2D but from a fixed 3D camera view. I think of this as a "2.5-D game."

Thanks again,
Henry
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Jul 2006 22:30 Edited at: 5th Jul 2006 13:45
set object should be used for hiding all black pixels from a textured object (see the help files for the right parameters, you have to set "transparency" to 0). I also think that ghosted objects don't show the black color.

The lock object should work... To get the height of the plain to fill the screen completely is tan((3.14/2.905) * 180 / 2pi) * distance * 2, and the width is that value /3*4 (or /screen height()*screen width()). Then texture the image with the HUD.


You can also start your loop with
paste image HUDImg, 0, 0
(the image has to be the size of the screen)


or change the line set object 1, 1, 0, 0 to ghost object on 1 for a ghost effect on your HUD.

But ofcourse, if you don't need a ghost effect, it would be much simpler to do:

(note the 1 on the end of paste image. It stands for transparency)

The variable data (like the radar dots or life) can be drawn in the loop itself.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
HenryTj
20
Years of Service
User Offline
Joined: 2nd Nov 2005
Location:
Posted: 5th Jul 2006 06:21
Thanks, will give it a try. I guess I was hoping to avoid coding brute force mouse over and click detection.

Henry
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 5th Jul 2006 10:14
Quote: "Thanks, will give it a try. I guess I was hoping to avoid coding brute force mouse over and click detection."


That's not hard, but you could use sprites if you wanted, and that has built in collision detection.

flock
20
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 5th Jul 2006 16:49
Hey, you came to the forums and wanted it served. You never asked for beautiful code. Otherwise, good luck.

a.k.a. "flockhound"
HenryTj
20
Years of Service
User Offline
Joined: 2nd Nov 2005
Location:
Posted: 6th Jul 2006 00:00
Quote: "Hey, you came to the forums and wanted it served. You never asked for beautiful code. Otherwise, good luck."


Hi Flock. Sorry if I have offended you in any way. It was not intentional. Im getting set in my ways as I get older. I am more used to well documented systems than what DBC has. Figuring out DBC seems to be more trail and error or word of mouth.

I am in a hurry to put together materials for a class. For the first time in years, all my classes (4 of them) are going this time. I have never taught two of them before (this is one of them.) The first couple times we offered this class only 2-3 people signed up. This time we not only got a full sign up, but extra people and the school has moved the class to a larger room. This class starts Monday so I am in a hurry. (I have 3 other classes and I am only a part time instructor which means I do other things too.) I wish I had the time luxury to figure out everything myself. This is for a short course of only 10 hours (2 houres everyday for a week.) Its part of a summer camp program for kids. This is the first time I have done the kid's summer camp teaching and I am not sure what to expect.

And "yes", I am looking for definative ways of doing things. In other words the better of the several ways of doing things that I can usually imagine. I learned programming back in the Fortran years when object oriented programming was still being developed.

I hope this explains my reasor for asking questions here.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 6th Jul 2006 14:05
Quote: "The first couple times we offered this class only 2-3 people signed up. This time we not only got a full sign up, but extra people and the school has moved the class to a larger room"


Sometimes you just have to show them what it can do

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.

Login to post a reply

Server time is: 2026-07-07 23:45:02
Your offset time is: 2026-07-07 23:45:02