So, my current project is to make a game, as you might have guessed. Ideally I want it to be so darn good I can sell it through some distribution service for a very reasonable price.
My first sub project (I’m easily bugged by not having certain ‘features’ of programs during development) was to build a menu that extended GameComponent, and was a pluggable, easy to implement menu. It has no flashy features (currently) and is not quite ready to release (it’s clean running, but I want to make the code a bit more flexible for possible future features). When it’s ready I’ll make it available on bomadeno.com
Using only a few lines of code, the menu looks like this:
And by picking that irresistible button…
A semi transparent bunny fill the image. Obviously (or not?) a bunny would not be the image of choice in a real game, but it allow you a few important choices:
- The menu background is an image showing some beautiful prerend of a scene in your game
- The menu is a transparent grey, using the real game (paused, potentially) in the background as an image
- A plain colour
- A slightly transparent image of something (maybe stars, clouds?) over the background. Although I haven’t tested it, pngs with transparency data should work too.
In case you’re wondering, the blue tint in these images is the ‘game’ showing through – a default otherwise unedited XNA project.
The features, then:
Choice of menu title position and menu items position (auto aligning to look best). Choices are top and bottom lefts and rights, and centred. Menu items can be automatically stacked under the menu title.
Menu item active and inactive colours can be set (the title is inactive colour, but I’m planning to make that so you can set it differently)
Menu items are added in the form of text-delegate pairs – so you have complete control over what they do. The menu listens for Escape key presses, and can hide and show itself. When hidden by escape it calls a user set ‘pause’ and ‘resume’ delegate to give you control over your game when the menu shows itself. You don’t actually have to set these… the menu will then just show and hide itself.
All in all, to get a menu with 2 options (resume/quit, maybe?), you need only 6 lines of code, and a simple but functional menu will work alongside your existing game. (not counting the methods that respond to resume/exit – I’m assuming you already have them. It makes the required lines of code look better! If you must be picky, the methods take another 6-7 lines depending on what you put in them)
Next time – I’ll either have added some game to the menu (woo), flashed up the menu some, or quite possibly done something totally different… You will have to wait and see!
Sounds interesting! I can’t wait to hear more.
And when you’re finally finished I WANNA TRY PLAYING!!!
You say we “will have to wait and see” like we’re holding our breaths to hear more about your exciting codes and algorithms… Geek 8D~
…
On a different note :D… BUNNY!!!
You will have to wait and see. Maybe I’ll decide to do some vectoring instead. 8D?