Well, my first meaningful post comes a little over two months since my initial kickoff post… as I said before, I’m not much of a blogger. 😀 Oh well, I’ll see if I can change that yet.
I’ve always wanted to write a role-playing game as it’s one of my favorite genres to play, but pulling it off is a pretty major undertaking as there are a lot of elements to pull together. However, I’m approaching it with a positive attitude and the mindset of adding a little at a time until I’ve got something usable, perhaps even fun… as all good games should be. 🙂
I started fleshing out some design ideas several months ago, so I dusted them off and looked for a good starting point. I settled on map generation, as I’d like my game to have a new, randomized world each time you play it… but also playable again if you like it. Basically patterned after Minecraft with an entered seed that is fed to your psuedo-random number generator to produce your world.
So the last couple weeks have been spent researching ways to generate interesting world maps (city and dungeon maps will trail along too at some point), and I’ve really had some fun learning some different ideas on map generation. I wanted something random but not just a bunch of garbage in little clumps, which is what you get with a true random approach. I wanted land features that were “random” but also natural looking. After perusing the Internets for several days, I decided to use a Simplex Noise algorithm to generate my world map. Simplex Noise is the big brother to Perlin Noise, both of which were written by a smart chap named Ken Perlin. I examined the Word according to Brother Stefan Gustavson on the subject (you can find a link to the paper at the bottom of the Simplex Noise wiki page) and I must say, it gets pretty deep into the math bushes… I was never a math genius and I don’t pretend to understand all the math behind the generation, but the general concepts made sense. I found a Java implementation that I rolled over to C# to generate a Simplex Noise and it works pretty good. I had some fun putting together that prototype as it produced some great results for me… I spent several hours just tinkering with it and looking at the generations. My prototype is a quick & dirty WinForms app that basically uses the generated noise as an elevation map and I assigned terrain types/colors according to ranges in the elevation. I posted my prototype on GitHub for anyone interested in seeing what it can do – https://github.com/ricke44654/SimplexNoise.
After playing with that for a while, I decided to refine it to use two noises – one for elevation and another for moisture, then combine the two to make more interesting landscapes. I then wanted to visualize the world close up with by “walking around” on the map, so I started to make a rudimentary viewer in my app with GDI+. After a little work, I had something going but wasn’t at all satisfied with the performance… so I decided it was time to start looking for a game engine. One thing I wanted was to have my game run on multiple platforms, mainly a PC and an Android device. I had dabbled with XNA back in the day and thought it was solid, but didn’t want to be tied to Windows specifically. A couple months ago, I stumbled on to MonoGame through my Xamarin development at work and it looks pretty sweet – an open source multi-platform XNA framework with just the platforms I was looking for and the ability to leverage the numerous XNA resources that exist out in the wild already… ching. But that still leaves some heavy lifting on the part of game engine mechanics, such as movement, collision detection, screen management, etc.
Enter Cocos2d-XNA, an open source 2D/3D game development framework built for XNA but supports multiple platforms through MonoGame as XNA is on it’s way out. I had seen some variants of Cocos2d around but nothing that I could really leverage in C#… until now. 🙂 My hats off to the chaps who put all this stuff together, it is some cool business. With that said, it has been a little challenging trying to learn how to marry these three technologies together over the last few days, especially the Cocos2d-XNA goodness which is very light in the way of documentation… they freely admit as much on their site and are working to improve it. No flames, boys… I know docs often come in last in the development cycle, I’m sure they’ll get better, at least I hope so. 😉 In the mean time, after getting frustrated with getting a basic running app going for a couple days, I looked up a book on Cocos2d programming (it originated on Apple iOS) called Learning Cocos2D: A Hands-On Guide to Building iOS Games with Cocos2D, Box2D, and Chipmunk. As I have access to Safari Online (which rocks!), I started reading immediately. The book lays out a pretty good introduction so far (I’m on Chapter 2) on Cocos2d architecture, it’s amazing how much you can do with just a few lines of code. I don’t know Objective-C or the iOS/XCode platform, but so far I haven’t had any trouble translating the examples into C# Cocos2d-XNA goodness, so it’s all good right now. My plan is to get up to speed on Cocos2d with this book, then leverage that learning to dig into my game.
All in all, it’s been a fun couple of weeks learning some new programming magic. In a future post, I’m planning to detail my navigation through the XNA / MonoGame / Cocos2d-XNA jungle on how I got my code up and running so maybe it can help anyone else who wants to pursue this course. But right now, it’s time to go to bed… 5:30am is going to come all too soon. Happy proggy.