Sunday 1 January 2012

My first attempt at 3D games in XNA 4.0

I've tinkered with XNA before but only to make 2D games.

My biggest being my 2D tile based game engine that never worked on the xbox due to my bad understanding of garbage collection on the xbox.

Anyway, I've decided to have another go at finally getting an indie game published on xbox live.

I first need a game idea to build and learn the trade as I go.

I wrote a flash game many years ago called argh aliens and it was basically a pseudo isometric lander game where you had to thrust accordingly to capture humans. It was a simple but fun premise so I thought why not remake it in XNA.

I started down the same path as before, trying to do it all in 2D as I had done in flash.

As I had never really done any 3D development, I thought it better to stick to what I know. But then I started hitting all the same problems I had with the flash game:

* Occlusion of the player sprite when it goes behind a building (solved originally using marks)

* Casting shadows on the buildings from the player to show your relative position (solved by working out the location of where a semi transparent sprite should be, but this looked less than pleasing)

* Losing sight of player when going behind a building (solved by not having smaller buildings in the distance #hack)

All of these issues are easy to solve with a 3D engine as they are naturally solved by:

* Occulsion will be handled by the z buffer and I never have to worry about it. Models in the foreground will naturally hide objects behind them.

* Light sources can be added and cause shadows to be cast on other objects in the scene (note: ok so shadows aren't that simple!)

* In a 3D world, I have control of the camera position and view point, so I can move the camera to always keep the player in view

So it seems obvious to me to step out of my comfort zone and try this game in 3D.

I've decided to blog about my experience just in case my learnings and mistakes help anyone else along the way.

The code is all publicly available on github (I will post the link).

I'm actually a fair way through the development but I will historically blog my journey up till the point I am now.

No comments:

Post a Comment