Monday 5 March 2012

It's so easy to fall behind

Well it looks as if I failed to keep this blog up to date!

The game has actually been finished and published on Xbox Indie Games (Under the name Argh Aliens link -> http://marketplace.xbox.com/en-GB/Product/Argh-Aliens/66acd000-77fe-1000-9115-d80258550aaa )

I will get some time to back fill this blog and add all the finishing bits that were required to get the game up and running (it spent about a month in Xbox Peer review!)

Tuesday 7 February 2012

Refactor

I've been through the code base and had a bit of a tidy up.

There is now a static class which holds all of the controls for the player, this is really useful as it maps an xbox pad button reference to a key so I don't have to keep remembering which key I assumed would be the start button!

I've also removed all game variables (like start lives, score multipliers. Etc) from the classes that use them as there was too much duplication and find and replace. Now there is a singleton options class that can be used to get option settings. Why isn't it a static class? Because I want to be able to set the values in the options if need be and static would fix them.

Another change is the camera and lights are now part of a scene object that is passed into the level.

Player objects are also now created at game state and passed into the level. This means I don't have to track player variables outside the level for when the next level is created. It makes sense as the state of a player exists across multiple levels.

It needs some nicer graphics too. I'll try my best!

Oh and an xbox trial mode!

Adding some incentives

So now you can collect fuel power ups to top your fuel up and also if you score over a certain number then you get an extra life!

Friday 20 January 2012

Creating state and screens

So far the game has loaded, jumped straight into the action and on completing a level just jumped straight back to playing.

I need to have some sort of naturally flowing state to the game such as...

Start page
Playing game
Level complete page
Game over page

And probably a Game paused page

This will allow the user to naturally flow through the main states of the game and provide input into what happens. Such as start or quit the game, pause play, see how well they did on a level or review how well they did at game over.

I've already got my enum to let me know what state my playing game is so I've added more states to this to represent these extra sections.

All I need to do is have some screens displayed to the user with a way of choosing options.

I've created a base Game screen class that draws a background image on screen and You can also provide it an array of menu choices which get rendered to screen. The default class also allows navigation and selecting menu items.

Now for each game state that requires a screen, I just extend this base class and add any custom functions such as displaying the end of level score or letting the user start a game.

There are much better state systems for XNA but this one is very easy to implement and serves my needs just fine.

Now my game has a nice flow of states.

Splash: check for user input to determine controlling game pad.

Main menu: can start the game, view controls or quit game.

Playing: game play mode

Paused: game froze, can also quit to main menu

Level complete: show score break down

Game over: show final score

Quit confirm: any time the user wants to quit just get them to confirm it.

Monday 16 January 2012

Creating the HUD

Most games have some visual representation of how you're doing in the game. This is usually represented via a HUD (Head Up Display). It's basically an overlay of important game information such as score, lives, weapons you have, etc.

My game is starting to shape up and is actually playable now, however I don't know how well or badly I'm doing because all of my game variables aren't presented to me.

So I need a HUD!

My HUD just needs to display my current score, my lives left, the remaining peeps I need to abduct and most importantly... how much fuel I have left before I crash.

HUD information is displayed in many different ways, from simple text, to icons to bars and other fancy graphics.

For my HUD I'm going to keep it fairly simple. Score is going to be text, Lives and Peeps Left are going to be text next to a friendly icon explaining the text and the Fuel is going to be a bar representing a fuel gauge showing how much fuel I'm burning through.

The text and icons are fairly straight forward, I've just used the SpriteBatch function to draw fonts on screen and other Texture2D items for my icons.

The fuel gauge again isn't overly difficult, all I've done is built a simple function that draws a single pixel in a given colour a certain width and height across the screen. Then I repeat this drawing to give the impression of a full potential fuel level (red bar) and the actual fuel level (green bar).

Then in my HUD class when my update code is executed, I just update the relevant variables from the game code and the HUD displays them accordingly.

Very easy to implement but makes the game a whole heap more playable.

One other thing I can see now is when I complete a level, my score and lives reset. This is because previously I was setting lives and score in the level and not keeping track of them in a global state. Simple fix and now when I progress levels my lives and score stay as they should do.

Sunday 15 January 2012

Adding a skybox

So far the game area has consisted of my 3d objects floating in a void of blue space. This doesn't look overly impressive for a game and I don't want to have to build an infinite 3D model of a city so it looks more realistic.

Most 3D games suffer from this issue of having to give the impression of a real world environment without having to build the full visible area (unless you're building a flight sim or something!)

The common solution to this problem is called adding a skybox.

A skybox is just another 3D object (usually a cube or a sphere) with the textures on the inside and then you ensure it moves according to your camera and all of your play area is located within the skybox object.

Then your textures applied to the skybox are of the background landscape and it seems as if there is a game world past the actual game world.

This technique was actually used in many Hollywood films, where a large matte painting would be hung behind the set to give the impression of a city or a large hanger bay full of X-Wings.

So to create my skybox, all I've done is to create a 3D object in 3D Studio Max made out of 6 planes with textures applied to. Load this object into my game and scale it up so it engulfs the game area. All I need to do is make sure the camera can never leave the skybox object and it all seems to work just nicely.

There are many other tutorials on how to create skyboxes in XNA and probably better, more efficient ways than what I've done, but this works for me and for this game so no need to tinker.

Sunday 8 January 2012

A bit more of a challenge

I've also added a game state so I know if the player is currently playing the game, completed the level, is completely dead or has completed the game (I don't think this game will have an end?!)

The game starts out with a small number of peeps to abduct, and each time you capture (or kill) all of the peeps, you move on to the next level where there is 1 extra peep to collect (a maximum of 16 peeps then it resets back to 3 peeps but with less fuel to start with).

When I said you can kill peeps, I don't mean in a fun shoot em' up kind of way. If you land hard on a peep and you explode, you kill the little chap meaning you don't get any points for the abduction but you can still complete the level.