So when we left off I'd just started telling you about the processes involved in coming up with the baddies for my game PowerUp. If you remember, I was attacking them in chronological order, my logic being that as my understanding of coding for enemy AI improved, so would the intelligence of my enemies... a logic which, as it happened, more or less made sense.
You can read Part 1 here.†
Well, in looking at the first two Chapters of the game, we've pretty much covered the basics of blind enemy movement around the screen. That's to say enemies who's movement is not based on where you, the player are positioned. Sure, their movement is well paced, gracefully animated and generally makes sense as far as nice solid moving enemy elements should, but the thing is... those early baddies can't see you. They're blind.
And I was sick of em! I wanted baddies that could litteraly challenge me. I wanted baddies that could see!! And that's what was foremost in my head when I started PowerUp Chapter 3. "Cracked Planet".
For the most part, I was finding that the process of coding my game was relatively smooth. Generally, As I concocted new and wonderful enemies, I'd just build on the ideas and the code that I'd developed in earlier enemies, twisting things a little perhaps, in the hopes of prompting a change in player tactic and most importantly, a change in optimal player weapon.
As I say, for the most part this was doable by evolving a bit of code I'd already written, saaay, making an enemy's right to left movement speed a bit less predictable by instead of having it initialise with a speed of 3.0, having it initialise with a speed that was randomly between 3.0 and 4.9.
Boom! Immediately, you've got a baddie type with considerably less predictabillity than its predecessor. Add to that, a vertical floaty-wobble from another previous baddie and you've got something that's more unique still... Finally, add a random directional bullet from yet another predecessor and... you get the idea, right. I was able to swap and change mechanics between enemies.
However, sometimes there were bits of code that I'd have to go looking for... Well, I suppose that applies to almost every bit of code the first time you use it, even when you're in a rythm, you occaasionally need to stop to gather clues on what comes next.
...And that's exactly how it worked with sighted baddies. It sounds simple in theory, but it took me the best part of a four hour coding session to locate the snippets of tutorial and example code I needed in order to find the syntax I required to do what seemed so simple in my head: And in this case, that simple task was to refer to the player's hotizontal and vertical position. Its Vector, if you will.
I'd messed with this stuff when doing the player's movement... I'd familliarised myself further with it all while dealing with baddie movement. But getting one class to refer to another's position, at first was hard work! However, when I cracked it I was like a kid in a sweetshop!
...and to begin with, I applied a bit of code to the creepy looking PINCraft that set its intelligence a cut above the rest. It said that if the player was above the PINCraft, move the PINCraft slowly up. If the player was below, move it down. Simple, but effective. This had two effects...
Firstly, the PINCraft became that little bit more deadly, or at least, it appeared to. Homing in on the player. Then attacking in huge numbers, the PIN gave the impression of oppression! An overwhelming force that was closing in on the player from in front, above and below. Choking and confining any freedom of movement. .....Ace!
But most importantly, the effective antidote battling to a PIN wave was to switch weapons. There were a lot of PINs, but they were physichally weak. Bullet-power asside, what the player needed was A LOT of bullets, and switching to the fast- repeating Plasma cannon while watching my step, I was soon cutting great gaps through PINCraft assault!
Closing in - In coding the PINCraft's collision, I was careful not to make those splayed pincers collideable with the player. Imagine how impregnable this wave would have been if they were.
But ultimately I had sussed the issue of aiming at the player... or so I thought. As it happens, for a baddie, aiming ones self at the player is one thing, but it turns out that aiming a bullet was something else completely, and something I'd have to face soon enough...
I had been pretty determined that when I reached the enemy planet and the dealing with locations that had floors, I'd have to take up the challenge and create a few grounded enemies. Early in the "Cracked Planet" Chapter seemed like a good place to start and my first land dwelling baddie was a heavilly armoured, armadillo-like little ATV called the RATCraft.
It was pretty obvious that a grounded baddie was no threat without the abillity to throw a few projectiles our way and supplying the RATCraft with a handy orb firing tail, I gave it just that abillity.
however, emboldened by my experiences with homing my PINCraft in on the player, I decided not to rest until I had RATCraft aiming its arsenal directly at the player.
First attempts were thwarted by the simple fact that I hadn't thought this through.
The PINCraft had been written in such a way that it was forever checking its vertical position in relation to that of the player and updating it, constantly homing in.
With the bullets, however, what I actually wanted was for the baddie to aim, shoot and forget. The bullet would then take the trajectory it was sent on, and just go with it... Trying to get a coherent google search out of that one was a bit of a mare, I can tell you!
It took a few nights of searching and blindly tapping possible solutions in before I found something that worked. What I did note was that the territory I was entering was no longer that of clean cut solutions, of code that you could just copy from a tutorial and paste into your game, changing graphics, speeds, etc. I was now entering the oblique territory of clues!
...Little bits of code, similar to that which you're looking for, but not quite it. Bits of code that hint at the kind of variables you should be thinking of using, maybe something that alludes to the possibillity that I'd need to acquire the enemy's position as a startPoint, then the player's position as a targetPoint, then work out a line between them just on the frame of the game that spawns the bullet, basing the speed of the bullet on the distance between the two points so that even close up, the player has a chance to see it coming and to move out of the way.
Desert Rats - This term is actually where the RATCraft originally got its name, but the Armadillo look it ended up with was based on a totally random design scribble I took a particular liking to.
I know that for an experienced, seasoned programmer this is obvious, but for a non mathematically minded sort like me, this was really new territory and the sort of thing I would have attempted simplistic workarounds for on my earlier games... but I had a feeling about PowerUp. The game was worth the extra effort. Not only that, but PowerUp itself now seemed to be pushing me on. Daring me to try new and dangerous ideas.
I stuck with it! ...and after a few more headache-laden coding sessions, I had a bit of code that targeted the player! I did it!!
Feeling cocky, I even used the PIN's position detection code on the RAT. The RAT would come in from the right, driving to the left. On passing the player's horizontal position, it would skid around, 180 degrees and start chasing the player until it was innevitably outrun by the scrolling of the screen.
The RAT's movement was a flourish of the non-necessary kind, but I was determined that it was this sort of flourish that would make my PowerUp baddies stand out as being just that little more alive.
I was approaching the middle of Chapter three, the halfway point of the game, and became accutely aware that the creation of more and more new baddie types was going to seriously slow down PowerUp's production. The use of more difficult variants of the growing library of enemies at my disposal was becoming a more and more realistic solution here. With my new baddie homing and bullet targeting skills, I resolved to investigate this properly.
Specifically, I revisited the FABCraft, the DEFCraft and even the dreaded RAYCraft!
The new FABCraft variants, or the "RedFAB" were bigger, slower and stronger against the player's firepower. the RedDEF shared similar properties when compared with their earlier predecessors, although now with the abillity to fire off infrequent, aimed shots at the player's ship.
Heat Rising - The inclusion of Red variants of previous PowerUp enemies turned out to be a great way to visually reference the raise the game's difficulty gradient without losing too much time or straight-repeating too many previous enemies.
The RedRAY were small, fast and difficult to take out as they came from the rear and their vulnerable spot was soon protected when their devestating ray weapon charged... much faster thn their predecessor, I might add. The red variants all worked really well in hiking up the pace of play while their familliarity alowed the player some expectation of what was to come. This approach also served to give me some respite from the gruelling task of forever concocting new and time consuming ship models.
...That RedRAY was still a little swine for bugs though!!
It was becoming apparent that the PowerUp was getting a bit heavy on the fighters and fighter size/class ships. The BATCraft, DEFCraft and FABCraft (While more of a mine, the current incarnations of FAB were more or less fighter sized) were beginning to outnumber the slow and lumbering forms of the likes of BUSCraft and RAYCraft. Even REDRay was closer to a fighter than a large-class ship.
As I'd started Chapter 3 with some new smaller offerings and proceeded to hurl red variants of familliar ships at the player in its mid section, I thought it was about time I rolled in one of the big boys... You have to bear in mind that at this point, I'd barely even considered what I was going to do about bosses, so these larger ships were as big as my imagination was currently allowing me to get.
I heaved in the MISCraft. MIS was basically to be a missile launcher. I realised that I'd managed your basic homing capabillities with the PINCraft and was beginning to wonder how well that code would translate to what was essentially an arc-based homing bullet. Of course, the answer to that was that it would translate just fine.
My modelling was speeding up now and after a little break to work on Red ship variants, I was only too eager to get back to a bit of original 3D art. I was also becoming a much tighter, faster modeller of ships, and found myself modelling far fetched but vaguely functional ship parts into MISCraft, the large funnels at its rear would be the source of the ships screen-right to screen-left homing missiles and I particularly took pleasure in dictating the precise starting-source of the missile in relation to the enemy firing it, as opposed to just firing it roughtly from the central area of the baddie as I had with the RedBAT and RedDEF ship classes. The MISCraft had an all together less chaotic, more deliberate feel to it.
At first, MIS also simply moved in from right to left, but I soon came to realise that I could experiment a little with this one. After plenty of earlier encouragement for the player to use their Plasma cannon, what with the weaknesses of the Cleaner, the RAYCraft and the PINCraft, I settled on a mechanic in the MISCraft that would limit the player's use of that particular weapon... A huge flickering lightning-like shield which extended from the front of the ship and spelled instant death on contact with the player. The shield was also long enough that anything but the very highest levels of plasma would simply not breach through to the craft behind.
I had the ship tank its way on screen then pause for a while with a menacing demeanour while its missiles swooped off toward the player. I wrote in an extra bit of code which had the missiles count down their vertical speed to zero when changing direction, then count up again when finding the player, giving them the impression of arcing around the player, as though dragging their own weight.
It worked wonderfully, the elasticated flight paths of the homing missiles as they came toward the player, weaving vertically up and down toward their target became a very effective distraction. After they had passed, I left another pause for the player to battle the MISCraft, then if the hulking enemy was still surviving the onslaught, MIS itself would kick its engines in, accellerating toward the player and finally off screen left. Very cool, and ever more complex than what had come before.
Hulking Mass - The MISCraft could take one heck of a pounding and with its complex shielding and intelligent homing missiles, it was the baddie that really started me thinking about my options for the Titanic level bosses to come.
About now, I was really seeing the benefit of combining a large enemy with a wave of small ones. While a player was able to handle MISCraft on its own, MIS alongside a herald of chaotic, screaming BATCraft became another story completely. With every new enemy or Red enemy variant I was creating, I was also creating another batch of great enemy combination scenarios to play with in my balancing of the game overall.
You read that right. Wouldn't that be ace? Just to be able to unleash hell on hundreds of (obviously inherently evil) ground troops using some seriously chunky firepower? Well that was the plan.
I was thinking, "Hang on... All this talk of fighter class ships and titan ships and here we are in Chapter 4, "The Cityplex", essentially one of the enemy species' major cities, and we haven't seen a single ground troop!... Hmm, would they even have ground troops??... This is MY game, and I say of course they would!!"
And do you now what?... They did.
Mountains of em'.... erm, but not so many as to make the wave impassable. That goes without saying though, right? ...so I toned down where I felt I had to and threw a load of very easy to kill, little silhouetted reptile men at the player, earning a mark for violence on XBLIG indie games in the process, but hey-ho. It was SO worth it!
Death from below - While the reptillian soldiers posed little threat on their own, they became a cunning distraction when coupled up with large enemies like the RedBUS.
The soldiers shared the RATCraft's basic left right code and I made adjustments causing them to visibly skid to a halt while aiming at the player ship as it passed overhead, then chasing after it and ultimately, once again being left behind by the game's scrolling. to the trained eye, one soldier alone would have obviously been something of a copy of the RATCraft code, but thirty or forty on a screen at one time was a frantic wave of troops, desperately defending their homeland against an unknown and very powerful assailant.
...It was all quite pretty too.
The soldiers fired off aimed bullets at the player from their little glowing firearms and became particularly treacherous when paired up with bigger threats.
It's probably worthy of note that while I was no longer populating with as many unique new ship shapes at this point, between the soldier and the BOLTCraft I had included a great many new Red variants, all exploiting these new tricks.
The BUSCraft and PINCraft had now recieved the Red treatment, improving on their speed, homing senses and aimed firepower while the SLOBot had been upgraded for the smaller, sighted REDBot, equipped with a wicked experimental fast repeating aimed shot that served to spray bullets in deadly squiggly lines across the play area.
It's safe to say that by this point, my two crowning achievements were definitely in creating baddies with the abillity to locate the player's X and Y positions, then adjust its own position accordingly, and in creating baddie projectiles capable of establishing its own position and the player's position on being fired, then creating a trajectory between the two... And I was exploiting both of these techniques to the full!
Dodge THIS! - RedBOT sends off a naughty little squiggle of aimed bullets your way as the bullet blasting RedPIN Craft home in on the player.
One thing I was yet to try was in putting these two properties together. That's where the BOLTCraft came in.
By now, I was exhausting the RedCraft available to me so I concluded the fourth chapter with another upgrade... a particularly nasty flurry of new BlackBAT ships. Yes, that's right, The BATCraft had just upgraded a second time and its level 3 variants were getting really deadly now. Smaller, faster, and firing of irregular successions of aimed bullets at the player, BlackBAT might be weak, but attacking in sudden bursts of great numbers, they were filling the screen with screaming doom in no time and creating slow moving clouds of aimed bullets.
Of course, a nicely powered-up player ship could handle their brittle little frames easily with a well placed round of Spread-Shots... But not when they were joined by the BOLTCraft!!
I was particularly pleased with the physique of the BOLT. It had something of a letter "C" to its shape, and in the open space at its front, a huge, clearly fatal lightning bolt thing was happening, which matched the resounding characteristic of the previous MISCraft ship.
Like the PIN, the BOLT would move from right to left, aiming vertically toward the player, when its Horizontal location met that of the player, insterad of turning and chasing as the RATCraft would have done, a surviving BOLTCraft, gave up the chase, fired up its engines and shot off to the left, dignity intact. (This was actually a characteristic also shared with the pin. Clouds of those things attempting to turn around and chase would not only have made for an undignified display, it would most likely have slowed the Xbox version to a grinding crash).
...However, unlike the PIN, BOLT was slow, lumbering but durable. It also fired aimed bullets in fast succession, essentially providing the player with windows between attacks before a dodge manouvre was required. As an early enemy, it would have been tricky enough on its own, but with waves of angry BlackBAT ships, the ground rules were being set for a higher standard of player.
The first batch of BOLTCraft were to be fair, a little too small to make full use of their frontal lightning feature, but I rectified this with the opening of PowerUp's final chapter, "Into Terranus"...
With its entourage of BATCraft and RedBAT fighters, the RedBOLT slowly eases into view. In a movement pattern almost identical to its small predecessor of the precious level, RedBOLT's seemingly only difference is in its threatening slow approach and its seriously durable armour... and the fact that there only needs to be one of them!
It's only as RedBOLT creeps close that the horrible reality of the situation dawns and as the mighty goliath kicks in its engines, you come to realise that it's too late! If only you'd ignored all those accompanying BATs and focussed your frontal firepower cleanly on the impending RedBOLT.
By now, RedBOLT's sheer size makes it a particularly difficult enemy to evade!
Creeping Death - Under the pressure of a powered up player, RedBOLT bears down regardless. By now I was really getting a feel for how effective Titans would be as bosses.
While it's not a new baddie, I felt that RedBOLT had enough about it that was unique to make it worthy of an exclusive mention within this BOLTCraft section. It seemed that just a shift of size and a few subtle changes to the code were enough in this case, to completely put the emphasis of this enemy on a frantic, against-the-clock, frontal assault!
So, I'd made a baddie that could detect and find your vertical position via the use of detremental integers... You know, that thing I was on about in an earlier blog where when a baddie goes past its target, it starts taking 1 off its speed, making for an arc, until it's moving in the opposite direction. Remember?... Right.
Well, in a nutshell, it's the thing that I used in older games when I wanted to make things jump in arcs as opposed to sharp up/down movements... which suck! Anyway, back to the point. This worked well horizontally with RATCraft and the ground troops, and it worked well vertically with PINCraft, BOLTCraft, etc when homing in on the player.
...So it was really just a matter of time before I tried experimenting with something that did this horizontally AND vertically... and what better enemy type for the job than one which, when animating, was non-direction-specific... something that I'd used before maybe... something like a GLOWBall mine??
If you cast your mind back to the previous part, you'll remember that the GLOWBall was a durable enemy from the first level that mostly made for a dodge distraction while taking on other enemies. Well, on Chapter 5, when the player was powered up to a level best described as "Well 'ard", those things popped like baloons when they even vaguely considered coming within a hundred feet of the player's ship.
Sure, they'd be just as deadly when touched, and for that reason would still make a good minor distraction at this point, but what if the real danger came from the much advanced Red versions of them?
The Red GLOWBall enemies were actually similar to the GLOWBalls in art only, at about half the size of their counterpart, the Red variant spawned at a random horizontal position across the screen-top and the screen-bottom, checking its own horizontal and vertical position in relation to the player's, then it would accellerate toward the player at speed. Upon missing the player ship, Red GLOWBall would then arc to a halt using a countdown of its speed variable (or a decremental integer), pass zero, then promptly start counting the other way. This would happen for horizontal and vertical movement!
Forcefield at the ready - It's the unnerving beginnings of a massive Red GLOWBall attack.
The result was a rotating GLOWBall mine which soared and wheeled around the player, constantly seeking our hapless ship until one or the other was destroyed. Its destruction would take a few shots of a powered up weapon, prefarably the Side-Shot, but the rate at which these things spawned was to make things difficult for anything less than a level 9 power up, urging the player to start thinking about getting all their guns to a full power of level 10. Pronto!
The Red GLOWBalls turned out to be a simple, but particularly effective enemy, and a bit of white-knuckle fun too.
It seems that the PINCraft really opened the pandora's box of wierd and freaky baddies, and TENTACraft was to follow in the same vein. While TENTA's head section was a fairly simple spikey-jawed, chomping mouth affair, its rear section was quite a slick collection of parts which came together to make rather a hypnotic impression that I was very pleased with.
As for its moves however, TENTA simply came up behind the player, homing slightly as it did and blasting the MISCraft's very own homing missiles at the player's rear end. It was a fighter class ship whose design was based mainly around encouraging the payer to utilize their Back Shot. This was one of those weapons I'd found myself skimping on up to this point in development, so the inclusion of a relatively durable rear-attacking fighter was intended to have the player thinking ahead and powering up accordingly.
...As it happened, this powering up the Back Shot thing wouldn't prove to be too much of a problem as the Chapter four boss I was to concoct later on would really help to fill that gap... but I'm getting ahead of myself.
Watch your back - The Tentacraft's first appearance is supplemented almost immediately with it's Red upgrade!
TENTACraft was joined later in this wave by its Red variant (We are on the last level after all) which was a slightly larger, stronger, faster version of TENTA. However, instead of firing aimed bullets, Red TENTA loosed the dreaded Red GLOWBall mines, this time as a weapon.
...It was so effective, that this was far from the last time that a Red GLOWBall mine was weaponised. but again, more on that in part 3.
I liked those BlackBAT ships from the end of Chapter 4... and now that I had the core coding skills for some seriously tricky baddies I wanted more level 3 enemies in black. Over the course of the final chapter, great big BlackBUSCraft ships began to make an appearance, free-roaming and barely penetrable, pumping out highly dangerous, slightly-faster-than-expected aimed bullets at a rate which simply refused to allow the player to get into a comfort zone while attempting to pummel the enemy with everything they've got.
Then there was the Black FABCraft, huge variants of the floating bombs with unpredictable firing patterns.
FABCraft by the dozen - Even powered up to the teeth, the stakes get high with these particularly well armoured last-level enemies.
There were also the nasty masses of Black DEFCraft, sweeping by en-masse and dangerously close in their abillity to home in on your location.
Not forgetting the vast armies of Black PINCraft, sticking tightly to your vertical position while unloading in your general direction.
And the sleek BlackBOTs blasting huge, tightly packed lines of aimed bullets, creating walls of floating death, impervious to anything but the perfectly timed activation of a carefully preserved forcefield.
The MISCraft even got one more outing in the form of the REDMis, based on the lightning shield and homing missile combination of its previous incarnation, this is a seriously well equipped bull of a ship! Even powered up to full, a player stands little chance of taking these down once the accompanying wave of hardcore BlackBAT fighters strike and distract! This places the player repeatedly in tight corners, changing the dynamic of the gameplay once again.
The big guns - Even at full power and cheating my backside off, I stil break a sweat fighting off these guys.
Suffice to say, if you made it this far, you'd be earning your victories!
You're tired, you're battle ravaged! You haven't stopped playing PowerUp for hours now. Look, you need to eat! ...Sleep! Just tear yourself away for sanity's sake..... but, you've made it this far.
Pick yourself up, Pilot! you've still got to run what I lovingly call The Gauntlet!! That's right... a nice long corridor of Gun Turrets! And these aren't just any gun turrets. These bad boys will be changing pace constantly... one moment it's manageable... the next, they're coming at you in fours! Fast-firing and furious, above and below.
...and just when you're getting into a rythm... I crank it to 11 and throw in some more baddies for good measure!
If you make it to that final boss you'll be catching your breath and calming your nerves first ...at least, that's what I have to do, and I designed the flippin' thing!!
Running the Gauntlet - Some sections of the final level would require fast changes between weapons to counter unexpected attacks, all while weaving between Gun Turret bullets!
(Obviously, the last level/Chapter of PowerUp was all about throwing everything, including the kitchen sink at the player, but I was sure to keep it fair. With a bit of practice, you'll be able to do this on Easy... with a bit of skill, you'll manage Meduim too... I won't lie, it's going to take a really good run to beat it in Hard, and as for Psychotic... Let's just say if you make it, please have the cameras running and send me the vid. I'd love to see someone manage that!)
There I was with a game full of enemies. I'd mastered the moving of baddies and bullets around the screen. I'd managed the generation of said bullets and various shot, impact and death effects. I'd even sussed out how to code things to happen in relation to the position and state of other things. Nifty!
By now I'd spent many a sleepless night coming up with the bosses I'd need to do this game justice, ensuring that each and every one was visibly distinguishable from the others and loaded up with its own brand of bullet-storm.
I was sure that If I were to start at the beginning of the game, and code these things thoughtfully and with the reverence they deserved, starting with the simplest and working my way to the most complex, I'd be able to do them all justice.
.....and I'll tell you all about that next time.
Thanks for following my blog this far guys.
See you in the next one.