Last weekend I visited the Binary Zone HQ, and spent a few enjoyable days with Kenz and his wife Natz. A bit of time was given over to the discussion of Citadel, and Kenz showed me a rather nice Paradroid remake called Freedroid (see links column).
I'd seen this when I was scouring the internet for Paradroid links, but hadn't actually downloaded or played it. However, it's a very nice remake with some nice touches and additions (particularly the ability to play the game in Classic mode). This highlighted what I consider to be the difference between Citadel and other remakes; what I'm basically trying to achieve is the 'next generation' of Citadel, rather than a strict port with extra effects. Though the game will retain some of the key elements that made the C64 version so good, there will be a myriad new features.
One of the most interesting aspects of Freedroid is its control system; the main character is controlled using the keyboard, while the mouse controls a cursor which is used to aim and fire bullets. What is interesting is that I was planning an identical system for Citadel (of course, the game will support joypad control too).
* * *
As is typical in the world of game creation, Freedroid stuck in my head for a number of days, and so - as a break from the Editor - I decided to tinker with the basic player controls. I'd normally shy away from game-specific code until the Editor was finished and the basic scrolling routines were in place, but the beauty of the control system is that it's modular, and thus, easy to rip out and insert into the game at a later date.
I already had a test-bed created, so I added the sprites for the player's ship Monitor, and included basic keyboard controls. Then I set about adding some basic bullet code, so the player could fire left and right depending on the lateral placement of the mouse pointer (all fairly basic routines just to get the variables set up and working properly).
And thus began the tricky part - how exactly does the player shoot a bullet in the precise direction of the mouse pointer? I knew there'd be some tricky maths involved (NOT my forte at all), so I took the liberty of popping on to IRC picking the brain of veteran coder Snakey. It turns out that, as suspected, I'll need to use the Sin and Cos functions (these allow you to calculate how far an object needs to move in the X and Y directions in order to travel along a given angle).
However, the issue remains, how do you calculate the angle between ship and mouse pointer? As it turns out, Blitz has a specific function for that very task; its name is ATAN2, and it does its job very nicely indeed. With this in mind, I expanded the basic bullet data structure to allow each bullet to have its own Angle and X/Y direction.
After a fair amount of research, head scratching, and examination of other people's code, I had the bullets working properly (all 80 of the blighters!), and Monitor can now move freely around the screen firing recklessly. As an extra touch, I added extra variables so that every bullet can have its own animation type.
So, after adding just a couple of routines - and learning a fair bit about maths in the process - the control system is already beginning to take shape; as a testament to how good the control already feels, I added a punchy sound effect when bullets are fired - before I knew it, I'd spent nigh-on 20 minutes racing around the screen flinging bullets everywhere! Excellent stuff!
