Getting to grips with C# and XNA

Since starting my “Blog A Week” policy, most of what I’ve written is about how I’ve improved Invertical. Whilst I find the ongoing improvements very exciting and hope you’ll love the end result, I thought I’d take an alternate approach this week. Instead I’m going to reflect on how a newbie can pick up and create games for the Xbox.

X-Orbtek II is being written in C# using XNA, which provides a huge library of game functionality and is proving a great backbone. I was a little nervous about making a game for XBLIG as the language, API etc was new to me and it had been quite a while since I’d used a “proper” programming language. For the previous few years most of my games were made using GameMaker’s GML, Javascript through Unity and also browser games written in PHP. However I’m loving it.

Being able to step through code is invaluable and I really missed it with GameMaker. Visual Studio is of course very powerful and I do like the fact that I can press “.” and I’m away! One of the favourite things that I’ve learnt is partial classes. The amount of code I have in my main function is pretty crazy and it is really nice to be able to split it up. Maybe thats a sign that these ought to be unique classes but one thing I’ve found is that I want to keep my list of objects in my main game class, eg list of player, list of orbs, list of enemies etc. However often I want one list to access another so that all needs to be in the main game class!

Not everything is amazing about moving away from GameMaker. It is certainly slower to get everything working. Perhaps the hardest part when moving from GameMaker has been creating different modes & menus. Everything of course runs through your main game loop. I’ve got a state machine in place to monitor whether my game is in main menu, game, options etc and update & draw that accordingly. Personally its a bit, well ugly. I do like being able to create rooms and just say, okay lets go to options.

So in summary, for prototyping I’ll definitely be sticking to GameMaker but X-Orbtek II is unlikely to be my last C# or XNA project. This has certainly reignited my love of programming! Now I’ve just got to improve.

Leave a Reply