So I'd just like to start by conceding that scripted dialogue is not my strongpoint.
I tried to make a few films back in my student days and they were, let's face it, pretty hammy... pretty bad! Still, I tried and resultantly I learned something about myself... Mainly that I'm better at drawing stuff than writing compelling stories, witty dialogue and believeable characters.
With that in mind I've been writing, re-writing, then RE-re-writing dialogue for my game, PowerUp. I know I'm not particularly good at it... but I've had some practice now, and thanks to that I'm not particularly terrible at it either.
Sure it's all an obvious mishmash of my sci-fi influences, piled up high with every "invasion" cliche in the book... but when PowerUp's HATI (your Holographic Artificial Tactical Intelligence) piped up that there was a "Dark Intelligence" at the heart of our reptillian enemy, it began to dawn on me that I might have a great subject for my next blog.
Let's find out if I was right, eh. Because in today's ramble, I'm going to tell you about...
Yep. That's right. I've decided to let you in on snippets of the process I encountered when creating enemies for PowerUp!
I don't mean that I'm going to bore and alienate you with reams of badly-written code (this is my first attempt at a C# game, after all), instead I thought that as I pretty much coded PowerUp chronologically, I'd go through a load of the baddies from beginning to end in the hopes that any fellow aspiring coders, designers, artists, sound technicians and musicians who follow my shenanagans might feel that little bit less intimidated by the seemingly vast complexities of this aspect of making their game.
I can only really speak for my own experience, but once I'd mastered the control mechanics, scrolling backgrounds and pop-up dialogue of my game, I personally became sick to my stomach at the idea of populating PowerUp with challenging and engaging baddies.
I found that coming up with enough variety in visual design and attack style just knocks on to too many of the game's other facets, which in itself can make it all seem pretty daunting... not to mention the technicallities of actually making it happen! All that said, once I stopped with the panic, broke the workload down and approached it in a calm, realistic manner, I began to see some light at the end of the tunnel.
I also began to see the process for the profoundly fun, rewarding and prolifically creative outpouring that game development is supposed to be, and that the creation of my baddies actually really was.
...That sort of thing is why we wanted to make games in the first place, right?
So there I was. My player ship, now universally known as "Weapon-F" worked! She ducked and wheeled around the screen with grace and poise. Her arsenal was formiddable, her finer functionallity all but complete. The environment soared by in thick paralax, jumping to the next silent, abandoned game segment on cue, tracking my progress through the game as I closed in on the empty screenspace that was my first level boss. It was beautiful. It was promising... it was boring!
It was time to bite that bullet and start thinking about baddies!
I generally go quite a while between my blogs, I put most of my time and efforts into the game, so admittedly I forget what I've written in previous blog installations. still, I'm pretty sure that regular followers will remember me mentioning that while PowerUp was inspired by certain classic games I played growing up, my decision to actually try to make PowerUp was mostly inspired by the advice of a good friend and a good tutorial that piqued my interest in creating my own XNA shmup. Alongside basic controls, the tutorial introduced me to the concept of thowing instances of an enemy at the player... Just a simple animating sprite that moved from right to left while the player dodged it, shot it, or was killed by it.
So far I was coping nicely...
After some head scratching and a spot of umm-ing and aaah-ing, I realised that with a little modification, I could turn this simple tutorial object into something just slightly more complex. I decided I'd start with a bit of space debris, rolling through space from screen right to screen left, but essentially mimicking what I'd learned.
Every second or so, my space debris would spawn another instance of itself, just off the right of the screen. It would then run a rotation animation (yes, animation. there was no mention of rotation in my lessons so I simply didn't have the nerve to even attempt it in code), while updating itself to move a few pixels to its left every frame of the game..... I say a few pixels, but I'd actually learned how to do this in vectors rather than real pixels. Vectors basically allow you to apply a decimal point speed, like say, "1.2" to the baddie rather than telling it how many pixels to move by. believe me, it makes things much easier later on.
Now it was just a question of what happens next... I decided that it I wanted to avoid being overwhelmed, I'd better deal with this enemy one action at a time. I started by looking at what happens when it goes off the left of the screen. The last thing you want is your game to crawl to a crashing halt half way through because over the course of a half-hour play of it, every single baddie is still running its code somewhere off the screen! Obviously, once my debris had reached and exited screen left, it was done with. I removed it without ceremony. Blink. Gone!
Next, it was a question of what happens when the debris collides with the player... Simple! I wanted the player to run its death sequence, and I wanted the enemy to remove itself. I tend to add whatever is needed as and when its needed so it actually wasn't until this point that I wrote the beginnings of the player's death sequence. It began as a take on the arc-up,-then-drop-off-the-screen death of many shmups of the retro era, but then I realised I could maintain a little control over the ship and even do something of a "parthian shot" death! Nice!!... hmm, but I digress and that's probably a story for another blog post. But what was evident was that there would need to be an explosion when player and enemy hit one another.
Adding an explosion was much the same as adding a baddie, except where the baddie was being added on a timer, the explosion was being added on a prompt. Later I went back and garnished my explosions with sparks, chunks and other bits of loveliness, but to start with, I had my explosion. And that was just fine by me.
I gave the debris the same outcome on collision with all of the player's projectile types... quite a time sink which I'm sure there's a better way of doing on my later projects, but in the meantime, a lot of player collision was copied and adapted for all of the player's projectiles, and now the player was able to shoot the debris right out of the sky.
And there it was! A fully functional piece of space debris with all of it's possible outcomes covered.
1. Hit player - remove with a bang and kill player.
2. Hit player's projectiles - remove with a bang and kill player projectile.
3. Bypass both player and bullets and get to the other side fo the screen - remove.
Upon playing the game through I came to realise that things were looking a touch repetitive. At the very least, I needed to add a few different variants of debris to this section of the game. Not only that, but I wanted to give each piece of debris some slightly different qualities of their own. I looked at what variables I had to play with and came to the conclusion that I could change the size, strength and speed of the debris pieces... so I did just that.
I made a few copies of my debris code and after creating a few graphical variants in Photoshop, making a few changes to the size of each debris' collision detection, and fiddling around with that decimal-point speed variable, I was able to forge several more bits of debris. The bigger they got, the slower they moved and the more shots they took to destroy.
Space Debris - as simple as baddies come.
Finally, I topped the attack-wave off with a nice big, tough monster chunk of debris... something of a little sub-boss.
A few of my actual design ideas were beginning to bear fruit, mainly the need for focussed powering-up of the player's weapons... but I'd also seen how once created, a solid bit of code could easily be re-used and adapted for the next enemy.
And that's exactly what I intended to do...
For me, the most sleepless nights are caused by two emotional states, accute anxiety, or wild creative excitement. Over the course of PowerUp I've had great cause for both, but for now I was happy to be feeling the pleasurable pangs of the latter.
I had just created a baddie for my game!!
Suddenly it didn't seem like such a black art. The possibillities were opening up and if nothing else, I'd be able to create a game with simple enemies that move in a straight line... not quite what I aspired to but certainly better than nothing, and definitely cause for celebration. Over the course of nights on end I lay awake in the darkness for hours before sleep finally caught up with me, pondering, visualising, reasoning, planning out a potential means for the creation of so many complex enemies.
There was so much that I had absolutely no clue how to do, but my mindset was changing. I was beginning to trust in my future self.
I'd learned this much. I'll learn more... but I was determined not to bite off more than I could chew, and for a while, I stuck firmly to this rule.
With the debris came the beginnings of PowerUp's storyline, and the next logical step for that story included a nice simple, but suitably threatening wave of enemy fighters. I looked to my debris code and made my alterations.
These were the "BATCraft"... and it's probably important to state that there was no complexity, time investment or higher thinking to their concept. They were to look a bit like bats, the name sounded cool, and I wanted to quickly get through the conceptual side of things and into the meat of making it happen.
I scribbled a five minute sketch of a streamlined little cylon-like fighter (that ended up not really looking much like a bat at all), blasted out a model in 3DS Max, textured it, rendered it and applied it to a variant of my space debris code.
Up until now, I'd been drawing everything in Photoshop. I hadn't put much thought into the visual style of PowerUp as I was totally engrossed in learning some coding basics, but now the visuals were naturally surfacing. It was occurring to me that I'd need to rotate some of my ships, and doing that in 2D would be time consuming and much less visually convincing than modelling and rendering my ships in 3D... BATCraft would become my test subject.
So far, the BATCraft was a sliver of a ship, it moved from right to left just as the debris had done. I began to wonder if I could make the BAT do some kind of attack formation... perhaps a barrel roll off the screen or at the player, while showing off it's curves a bit... Yeah!
After a couple of frustrating evenings (I was working as a casual games artist in the day at this point, so PowerUp was getting a few hobby-hours, two evenings a-week), I was just not getting my head around how I was to make the BATs actually aim themselves at the player. "Well, it's early days" I thought. "Maybe I should keep them simpler than that". I did.
Instead of attacking the player directly, which I vowed to make baddies capable of later, I decided to set a mark exactly half way down the play area. The BAT would move slowly on from the right , then at a certain "go" point on the screen, it would assess whether it was above or below that half-way-down mark. If it was above, it would roll down, if it was below, it would roll up.
I did this by having the BAT spawn with a vertical speed (much like the horizontal speed inherited from the debris) of zero. At the "go" point, the BAT would play a firework-style scream and both it's horizontal and vertical speed would start counting. I'm told this is known as an "incremental" or "decrimental variable" depending on whether it counts up or down and while there's much more effective ways of coding its behaviour, apparently it's very good for stuff like jumping or falling through the air when a character is hit... and for a ridiculously naive and self satisfied moment (it turns out you have a lot of those as a beginner in anything), I thought I'd invented it... div!
Anyway, I applied the BAT's newly rendered frames of rotation as the craft counted up (or down) it's vertical speed and once the BAT was vertically off the screen, I applied the same bit of remove code that I'd done to it's horizontal exit and everything was pretty much tied up.
Screaming stupidity - BATCraft are the kamikaze grunts of the reptile race. At this point, each enemy took about 4 hours to design and model, then another 4 to texture and render. At 8 hours a-week, this constituted a week's work on PowerUp.
It was at this point I noticed the flaw in my BAT-plan... No matter how I fiddled the speed numbers, all of the ships in the wave were attacking one area of the screen. there was always somewhere you could hide in a bid to pretty much avoid any fight whatsoever. The solution was fairly obvious...
I created two more sets of BATs, each with fiddled numbers, each designed to attack areas of the screen in which the player was likely to take refuge. I now had medium range, long range and short range BATs. I even segmented the attack waves so that the medium range ones attacked first, lulling the player in to a false sense of security, before hitting out with the long and short range assailants.
The overall effect on myself as a player was just as I'd intended... to force a fight. I quickly found myself seeking out my most effective weapon for dealing with BATs and then using it in abundance. again, my weapon-swapping design ideals were being validated nicely in a way that I was capable of manipulating as I created more of PowerUp's enemies.
I'll leave it for you, the player to discover the best weapon for the job when it comes to the vast majority of my PowerUp baddies, but with some, I make it pretty obvious. Looking at my weapon selection order, the next in line for early demonstration was the Backshot.
As the last of my BATCraft screamed out of view, it occurred to me that a further attack of fighters would look straggly and un-memorable. What the game needed next, was something big and chunky. Something akin to a flying bus... with guns!
I grabbed my sketch book and scribbled up the BUSCraft (no, really. That's what I called it... and that was why).
Another evening's work and I had my BUSCraft modelled, textured and ready to go into the game. A further batch of sleepless nights and I'd pretty much figured out how it was going to work.
This time, instead of spawning screen-right and moving left, I would spawn three on screen-left, in set positions. They'd move slowly right, hang around for a while, then if the player hadn't destroyed them with a flurry of well placed backshots, the BUSes would roll back off to the left. Once off screen, they would remove themselves and the game would carry on.
There were a few complications I hadn't accounted for here. Previous waves had spawned at random vertical positions making for an unpredictable barrage of baddies. That worked for them but these big guys needed to appear in formation, even with slight delays in their appearance if possible. It took a bit of extra work... fiddly work too, but eventually I had little timers going off at the right intervals to make the BUSCraft roll on one at a time, hang around, and roll off...
Next up was to make them a threat and give the player a reason to want them dead!
I was hoping to figure out the mystery of getting baddies to aim for the player at this point, but it just wasn't ready to happen for me, so after losing a few more nights of work to my attempts at it, I looked for an alternative... There's a lot of this sort of compromise early on. Thankfully less and less later.
I decided that if I couldn't aim directly at the player's current position, I'd create a bullet that shoots in say, eight random directions... though mostly forward so that projectiles are more likely to hit the player. I then adjusted the frequency of the BUS's shots to add to the challenge element of this slow and lumbering craft.
It's probably worth noting here that as I hadn't sussed rotation, I opted not to go with line shaped lasers, missiles, or anything like that for my multi-directional bullets. Instead, I created a perfectly round enemy projectile, glowing white for clarity. This way, an enemy bullet would be able to travel in any direction with just one animation and it could rarely be argued that an enemy bullet was unfairly hidden. the round bullet is far from an original concept, but its usefulness is worth a mention, I feel.
I was expecting to be able to move onto my next attack wave, but playing through, there was this wierd sense of static about the BUSCraft. As the three rolled on-screen, they looked oddly robotic and stunted in their movement. Quickly, it dawned on me exactly what was needed to bring these single framed golliaths to life... Floaty-wobble!
Yes, you read that right. These vicious monster-master race types, sent to wipe out humankind in the most brutal unfeeling manner were in desperate need of a bit of floaty-wobble.
Let's say I add one of those incremental integers I mentioned earlier to the vertical position of the BUSCraft... just a little one, that counts up slowly. The count-up might start at -2.0, then count up by 0.01 per frame of the game, passing zero and continuing to count up until it hits 2.0. What we get when we add this number to the BUS' vertical position is the impression that the BUS is jumping slightly, in slow motion. Arcing, if you will.
Now, if we wait until the BUS's vertical floaty-wobble speed hits 2.0 then make it switch to an identical bit of code that tells it to count down from 2.0 to -2.0, we'll get it doing the same slow motion jump thingy, but downward... With me?
Once it's done that, I'd switch it back so that it effectively loops the sequence and Voila!! A nice up/down floaty wobble for the BUSCraft! ...One swift copy of that code and a little adjustment so that it does the same thing horizontally, and before I knew it there were three big BUSCraft floating on the screen in a much more convincing and satisfying manner than I'd even hoped for before.
Things are escallating now: Taking on multiple enemies with the BUSCraft and some GLOBalls.
Even by now, you can probably see how with each baddie I was adding another bunch of tricks to PowerUp's host of enemies. I'd decided to go chronologically through the game, creating enemies which drew on the skills of the previous enemies while adding a few moves of their own... and it proved to be quite an effective way of going about things.
After some prolonged testing with the BUSCraft, I came to realise that the static feeling I'd picked up on before wasn't just coming from the baddies. The linear paths and slow movement of the BUSCrafts' bullets meant that the player was able to hang around in one place far too readily in order to kill a BUSCraft. It seemed that even at this early stage in the game, the BUSCraft would need some additional distractions to keep the player on their toes a little more.
For this purpose, I concocted the GLOBall. A big, slow, floating mine which spawned ahead of the player and whose toughness against early projectiles put an emphasis on avoidance rather than on attack, this emphasis was made especially potent considering that at this section of the game, the player would be focussed on taking out three BUSCraft with the Backshot!
...It may have looked like an enemy craft, but as far as the code was concerned, the GLOBall was basically a very sturdy piece of space debris which borrowed the floaty-wobble code from the BUSCraft. Alone, it would make for an ineffectual and flatly, boring attack wave, but as an additional distraction for already populated areas of the game, the GLOBall worked a treat and took me out a few times, I don't mind admitting!!