Programming Menus for a game

Started by
5 comments, last by M4573R 15 years, 3 months ago
I'm currently working on a game in a 4 man team. We've mostly put off making menus until now. We're between engine proof and alpha. None of us have programmed menus before, and I'm not sure how to integrate them into the engine. As far how how they should be set up and how to get pause menus working properly. Are there any books that go over some of this? Thanks
Advertisement
Perhaps program the GUI functions and events in chosen programming language (C/C++/C#/etc), setup and call menu events in chosen scripting language (Lua, Python, UnrealScript, or otherwise), after loading XML for the settings/content.
010001000110000101100101
A lot of other people are using lua, but we aren't. None of us really know why its needed. Anything we want data driven we just load ourselves from files.
It depends on what kind of menus do you want to have exactly, I mean should this be a window based menus (like in HL2) or you need simpler thing like in COD4 for example, i.e. no windows, but only main window.

Generally, you will need to decide how would you process user input, i.e. you will want to do mouse picking (menu items are selectable with mouse) or you can select menu items using keyboard arrow keys instead. After done, you should decide how you will represent menu items, I mean should this be a text (must have fonts available in your engine (well, you will need fonts anyway), or it will be image based, or maybe you will want to draw rectangle then alpha it and place a text inside rectangle as well...

Scripting ain't really required, you can hardcode menu or simply load menu items from config file, of course you will have to parse config somehow if it's a text based data, or you can store your info in a binary file too.

Also take a look at NVidia Nature demo, it has a simple menu (controlled with mouse, but it also supports XML loading) you can start with.
menu shouldnt be hard to do.
its not that hard to even make your own.
what i would do would first to understand how to print sprites on the screen, lets say i want to create a button? then i'll print a picture of a button to the screen, make an event that checks if the mouse is between the right edge and left edge of the button(will do too with up and down), if yes then the mouse is over the button. then i would also make an event that checks if while the mouse is over is the left button down, if its then the button is clicked.

ehh, i might not have explained it very well but i belive you got my point. menus are mostly like buttons and are not hard to make.

i made a fast search in google and thought this might help you :
http://www.toymaker.info/Games/html/sprites.html
http://creators.xna.com/en-us/samples/gamestatemanagement

Take a look at that, ive been using a modified version of that menu system and it works nicely. (C# XNA but easily changable to your desired language and API, the concepts stay the same)
Game development blog and portfolio: http://gamexcore.co.uk
Thanks for the info. We've been going at it but loading in the coordinates, text, and 1 variable for each button from a text file. Each file is a menu. So if we want to create a main menu, there's a MainMenu file that has a list of buttons in it. What they do is hard coded. We will use both mouse and keyboard input for different menus. The actions the buttons take are executed through a delayed callback system. I like the example linked by gameXcore, but unfortunately the engine would have to be rearranged too much to get that to work. I'll also look more into the NVidia Nature demo.

Thanks

This topic is closed to new replies.

Advertisement