Get the latest Education e-news
 
Old 12-29-2008, 12:46 PM   #1
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default Menu System && HUD

I want to learn to implement the game menu-system and how does changing various options in the game menu affect the game-play.

I want to learn to program the same.. Can anyone please guide me in the right direction or give me some link which deals with this ?

I think, this also follows in the league of menu systems, but I also want to learn to make a HUD. The way I do it now is pretty cheesy since what I do is; for example, if I have to make a button at x,y. I make a texture, draw it at x,y and whenever u click in that area of the screen, i check to see if the mouse coordinates are within that area and then i just perform the necessary action. This really sucks when I have to change the resolution of the screen.

The right way would be to setup an event-delegation model or something like that..but i dont have much leads on this subject. So, please let me know something for HUD as well.

Thanks
brainydexter is offline   Reply With Quote
Old 12-29-2008, 08:21 PM   #2
yaustar
Administrator
 
yaustar's Avatar

Activity Longevity
2/20 19/20
Today Posts
0/11 sssss2261
Location: UK
Default

Why can't you make the HUD resolution independent?
yaustar is offline   Reply With Quote
Old 12-30-2008, 07:33 PM   #3
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default

It just stretches the textures that is rendered and it looks all messed up..
brainydexter is offline   Reply With Quote
Old 12-31-2008, 01:32 AM   #4
Marco Roy
Senior Member

Activity Longevity
0/20 17/20
Today Posts
0/11 ssssss156
Location: Montreal, Canada
Default

The simplest way to do this would be to use the on_click event of the object. However, I do not know the programming language you are using, nor if it has events.

If not, try creating a class for each object, put all of your objects in a collection, and on each click iterate through that collection to see if the area clicked corresponds to an object. This can also apply to non-HUD objects, such as enemies, for example.
__________________
Aspiring game designer and software engineering student at École de technologie supérieure (ETS)
CONJUREIGDA ProfileLinkedIn ProfileFacebook PageMy Website
Marco Roy is offline   Reply With Quote
Old 12-31-2008, 12:17 PM   #5
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default

Yea. I feel my post was more abstract. But, I am currently in C#-XNA. And I'm making a transition to C++ =>openGL. Thus, I am all ears for either of the languages since its the concept that I am looking forward to.

I understand the event delegation model, but whatever I had used till date had such a structure already built-in with events registered onto it.(am referring to java and the button-event system therein).

Here, I dont have that kind of a structure..so do I need to make something similar to that ?
brainydexter is offline   Reply With Quote
Old 01-01-2009, 11:42 AM   #6
yaustar
Administrator
 
yaustar's Avatar

Activity Longevity
2/20 19/20
Today Posts
0/11 sssss2261
Location: UK
Default

To be honest, I think you are making it more complicated then it needs to be. As long as you have a list of 'clickable' objects that you iterate through when the player clicks, you are fine.

As for the resolution issue, have the texture at a decent resolution to start with then in the worst case scenario, it gets scaled down.
yaustar is offline   Reply With Quote
Old 01-01-2009, 08:21 PM   #7
nef
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss58
Default

Quote:
Originally Posted by yaustar View Post
As for the resolution issue, have the texture at a decent resolution to start with then in the worst case scenario, it gets scaled down.
Another idea for the resolution thing is keep position as percentage. 0% in the x is position 0, position 100% is screen width times 1.0. 55 is screen width times .55 ect.

Your graphics wont scale, but be properally positioned, so changing to a larger position just gives the player more screen room, if this is what you want.
nef is offline   Reply With Quote
Old 01-01-2009, 08:52 PM   #8
nef
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss58
Default

As far as actual HUD design goes, you have millions of options.

People specialize in GUI design, it's not something you can get right, right off the bat. I'm also led to believe it's not something you can do perfectly.

I'd agree w/ yaustar here. Don't over complicate what your trying to do. A simple list of gui objects you check for mouse clicks and evoke their OnHit method, or whatever you want is probably just fine.

The most basic HUD i would go w/ would be something like this:

GUIObject (Base class any gui object derives from, buttons, text boxes, scroll bars ect)

The GUIObject would have these functions:
RegisterClickAction()
OnClick()

So when you create a new GUIObject, you can call it's RegisterClickAction and pass in a function pointer. The OnClick may do some specific things (show the down graphic for a button for example) but it also calls the registered function, if one exists.

Then you can create custom functions outside of your system for each button and assign your buttons those functions. You can get slick and even script out those functions to have a scripted GUI system.

Give GUIObject a Z priority variable and keep your list sorted by Z priority, check starting from the top most and stop checking for clicks the first one you get. Now you cant click multiple buttons at once, and the buttons on the topmost are clicked instead of the one below them, that solves a couple problems for ya too.

GUI systems can be extremely complicated beasts. I reccomdend going w/ a simple implementation that works for what you want.

You can get into observer patterns and all sorts of quirky shit to make a truly badass GUI, but just remember to ask yourself, "Is this really necessary or important?"

have fun

Last edited by nef : 01-01-2009 at 08:55 PM.
nef is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
All times are GMT -8. The time now is 06:38 AM.






UBM Tech