Sunday, February 16, 2014

Into the Citadel...

Yesterday I spent an entire morning re-reading my Blog from the last ten years (it's amazing how well I can remember coding sessions from 2006, but can barely remember what I had for lunch yesterday). My motivation was really twofold: firstly, I wanted to try and re-capture some of the drive and enthusiasm I had back then, and secondly, I wanted to re familiarize myself with some of the ideas and concepts I had for Citadel, way back when.

I also took the liberty of going through my Citadel design notepad which I scribbled in religiously during my university years from 2007-2009 (word to budding designers: write every idea down, and make sure you keep them - you never know when you may need to draw from them). It was an interesting read, and of course, it's always rewarding when you manage to impress yourself with an idea you can't even remember having!

* * *

Today, faced with a snowstorm outside and not much else in the way of commitments, I decided to sit down and start plugging away on the game. I needed to try a new way of working, and so I just dove in with no real game plan, and no desire to get it right (merely, just get it working). I already had my Mayhem testbed to work from, so I ripped out the collision system and began adding Citadel assets.

One of the first things I like to do is set up a basic shell, so that the game starts with a title screen, which links to the game, and in turn links back to the title screen. It not only makes the project instantly feel more rounded, it also gets you thinking about structure from the outset (there's nothing worse than having to take a pile of demo code that works perfectly, then break it into a million pieces as you try and fit it into a framework later on).

After the basic shell and collision were in and working, I imported sprites for the main player ("Monitor"), a test enemy, and a trap. The player control system was up and running in its most basic form fairly quickly, and within a few minutes I was roaming around the first level of the game looking for things to kill. :)

The next idea was to try and get a simple trap in and working (in Citadel, enemies, pickups, and switches are spawned from traps, which open as they player gets close). A fairly simple idea resulted in me banging my head against a wall for almost an hour trying to get a few simple lines of code to work.

After a shower and a little time to think, I came back to the keyboard and Googled the command in question, and managed to find a really common-sense Wiki which listed common mistakes for each of the Game Maker commands. Needless to say, I was making one of those mistakes, that of my code being called in the wrong event. Twenty seconds later, the code was working and the balance of the universe restored. :)

* * *

After lunch, I returned to the game to start refining a few things, including the player control, animation, and collision. In Citadel, the player moves one tile at a time (a quaint idea which gives the gameplay a unique twist), and luckily I had a testbed written in Blitz Max from 2010 that did the job perfectly; thankfully, it was a relatively simple process to translate this code to GMS.

Next came a slight tweak to the collision system. Due to the fact that the player moves on a square-by-square basis, the collision is actually quite simple: in essence, the squares around the player are analyzed before the player moves, so there are no checks to see if the player is colliding when they are moving, just checks before they move to see if the adjacent squares are free.

Once the control and animation were working as intended, I rounded off the day's session by tweaking the trap code so that it opens when the player gets within a certain range. Now the real magic begins: making the traps spew out enemies. :)