Why use C# to build a rougelike game


Whats all the fuss about Rouguelike games?
If you haven’t heard about Roguelike games – it is time you get started. Roguelike’s are best summed up by Wikipedia:

“The roguelike is a sub-genre of role-playing video games, characterized by randomization for replayability, permanent death, and turn-based movement. Most roguelikes feature ASCII graphics, with newer ones increasingly offering tile-based graphics. Games are typically dungeon crawls, with many monsters, items, and environmental features. Computer roguelikes usually employ the majority of the keyboard to facilitate interaction with items and the environment. The name of the genre comes from the 1980 game Rogue.”
Wikipedia 2012

Its a strong Indie game development movement that is growing at a significant rate and has attracted  enoormous interest from a lot of gamers who are slightly over the overflow of First Player Shooter (FPS)  games going around.

Why would I use C# to build a roguelike
Although maybe not the most obvious choice for general game development – C# is well suited to a good old school roguelike because it is such a simple and brilliant language. The following are the big reasons I think that make it a great choice for developing a roguelike game. You can find more information on the use of C# for roguelike development at http://www.domscode.com

LINQ
Without a doubt the power of LINQ minimises a lot of code and keeps your code really quite neat. Think about a simple Object model like:

DUNGEON -> LEVELS -> ROOMS -> ITEMS

So this says that a dungeon can have multiple levels, and each level can have multiple rooms and each room can have multiple items. Now if for some reason we wanted to determine the number of items in a given level (lets say we have currentLevel) we could do something like:

 var countItemsOnEachLevel = from l in dungeon.Levels
                                        from r in l.Rooms
                                        from i in r.Items
                                        select i;
            Console.WriteLine("Items on each level {0}",
            countItemsOnEachLevel.Count());

Or lets say we have

DUNGEON -> LEVELS -> MONSTERS

So again this means our dungeon can multiple levels and each level can have multiple monsters. Now if we need to work out the number of monsters alive on each level

var countMonstersAliveOnEachLevel = from l in dungeon.Levels
                                                from m in l.Monsters
                                                where m.HitPoints > 0
                                                select m;
            Console.WriteLine("Monsters alive on each level {0}", 
            countMonstersAliveOnEachLevel.Count());

Full OO support
The use of Inheritance, Encapsulation and polymorphism is quite critical to building a good roguelike object model.

Great Community Support
There are so many great sites to get support on C# development and the shear size of the development community means that you don’t have to go far to get answers to questions or advice on C# dev issues. C-sharpcorner,stackoverflow,msdn are just a few great sites to get assistance.

Free Dev Tools
VS2010 express is fine to build a roguelike and of course its free.

Want to know more about Rogelikes
There are lots of places to find more information but a couple of great places to start are:

http://roguebasin.roguelikedevelopment.org/index.php/Main_Page
http://www.roguetemple.com/
http://roguelikeradio.blogspot.com.au/    (This is quite brilliant!!!)

Happy coding and adventuring

Dom

Advertisements

One thought on “Why use C# to build a rougelike game

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s