A menu for an(y) XNA game

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:transparentsilvermenu

And by picking that irresistible button…

transparentbunnymenuA 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!

First Impressions of XNA

One of my real ‘things’ is playing and developing video games – ideally I want to work in video game development, and that was my plan until a certain bank turned down my application for postgraduate funding (and there’s no way I can afford the costs from my own savings). So, instead of my MSc course, I’m having to teach myself… No doubt I’m going to miss out on a lot of stuff this way, but it should still give me enough of an edge to get into the industry. (especially if things go as well as I want them to)

My current ‘project’ is a sort of bubble shooter, and it’s just in the design stages at the moment, but as experimentation I had a go using Microsoft’s XNA game studio – and I’m really impressed. Working through Riemer’s 2D tutorial showed just how simple it is to get a playable game up and running, and laid the groundwork on lots of basic useful stuff for getting the bubble game off to a healthy start.

Having used MOGRE before to do my 3D solar simulation (you can download it here), I know how tricky it can be to get things going – I would say that in XNA (in 2D at least) it is much easier. Though this may in part be due to my experience from MOGRE, I’m pretty sure XNA is the better. It also performs better on the cpu, by only calling update 60 times a second – stopping the massive load on the CPU I encountered with MOGRE (renders and updates as fast as it can). The 60 times per sencond also makes animation and control much easier!

So I will continue to work with XNA, and this week I’ll be trying to get a set of reasonable 2d graphics ready for use in the prototype stage. I’ll post screenshots and so on when I have some.

About me – Bomadeno

I’m Bomadeno. Aka Matt, and the administrator of this domain. I’m interested in computers… pretty much every bit of them – some might call me a geek, and they would almost certainly be right. Thankfully that’s no bad thing in the modern day and age. I enjoy developing computer things, learning computer things, and using computer things, be they hardware, software, games, applications, programming languages…

Computers aren’t my only interest – I also enjoy photography, chatting and going out with friends (or staying in with friends, playing LAN games…), drawing, and when I can, I like getting out into the hills and enjoying the fresh air.

My posts will probably be about computer development, games or creative stuff – or nothing at all whilst I’m too busy actually playing around with those things to write about them. That’s what all my co-authors are here for though!