Monthly Archives: September 2016

Jetboard Joust Devlog #44 – Shotgun Logic

Time to leave enemies for the time being and move on to weaponry – really the last missing piece of the puzzle. If I’m going to make any new enemies they need to be tougher and it’s impossible to gameplay test them effectively with the underpowered pistol which is all I had implemented up to this point.

The first weapon I wanted to build was a shotgun, but before I got into designing the weapon itself I needed to think a little harder about how weapon swapping and ammo supply works in the game.

Up to this point if you run out of ammo you basically have no useable weapon available. This makes logical sense but seems kind of harsh. It becomes impossible to defend oneself so, unless there is an obvious ammo cache onscreen, death is pretty much inevitable. I needed to find a balance between keeping the necessity to drop down and pick up ammo caches (I like this part of the gameplay), not leaving the player totally ‘high and dry’ and not leaving them overpowered either.

My current solution to this is to use the pistol as a default weapon. If your current weapon runs out of ammo you will switch to the pistol automatically – if your pistol runs out of ammo then an ammo cache will automatically drop onscreen making it easy to reload but still, hopefully, enough of a pain to make the player try and avoid this situation if possible. Your ‘old’ weapon is placed in a weapon crate somewhere in the world meaning it can be retrieved and is not lost for good. These aspects of the game design may well need tweaking but at the moment this seems to provide a decent balance between the various parameters.

So, once the above was implemented, shotgun time! I thought the shotgun would be a pretty easy weapon to create but as it turned out I was wrong, no surprise there then.

First thing I did was work on the visuals. I ended up adding three different particle effects – one to represent the ‘pellets’, one for smoke from the barrel, and one as a kind of abstract explosion effect to give some idea of the effective range of the blast. I also added a very short sprite-based ‘muzzle flash’ animation. My weapon superclass already handles barrel recoil and recoil for the player so I put a nice bit of knockback in there to make the blast seem pretty weighty.

Lastly – collision detection. This is the part that I thought would be easy (as the shotgun blast is a one frame ‘hit check’) but turned out to be more complicated. You can’t get away with simple rectangle-based collisions (as I use in the rest of the game) as the blast range is really an arc, like a slice of pie. Fortunately some time ago I spent a while implementing some SAT-based collision detection routines in my game libraries so I could call on them now – luckily they worked (which is a good job as I remember SAT-based collision checking was pretty complex and I had no desire to go back rooting around that code)! What I do is approximate the blast ‘arc’ with a simple polygon and check whether that intersects the enemy’s collision rectangle. This seems to work fine (though I ended up widening the ‘hit range’ around the muzzle of the shotgun more than you see in the GIFs). I calculate the damage done to each enemy based on the distance from the muzzle both horizontally and vertically – a maximum 50% reduction in damage each way.

The next issue to raise it’s head was that I had to stop the shotgun blast being effective through buildings. This seemed like it was going to be complicated, I’d have to trace a line between the blast and the point it hit the enemy and see if any buildings intersected it, but I managed to implement a much cheaper solution which seems to work fine. All I do is see if there’s a side of a building between the shotgun muzzle and the enemy. If there is and the muzzle is below the level of the top of the building I assume the blast is blocked (as it would be the vast majority of the time). If the muzzle is above the top of the building and the top of the enemy is below the top of the building I also assume the blast is blocked. These two simple checks seem to cover off most scenarios realistically enough.

Once the shotgun was working as a weapon for the player I then needed to try arming the enemies! Because of the way I have structured my classes this was pretty simple but unfortunately it uncovered limitations in the enemy AI.

Up to this point I had been assuming an ideal place to shoot at the player is with the barrel of the weapon level with the centre of the player. This is still true with the shotgun but it won’t be true for all weapons (for example a grenade launcher) and there also needs to be additional logic for when an enemy decides whether to fire or not which takes into account the blast range of the shotgun.

So what I’ve done is implement two different methods as part of my Weapon superclass. One returns the ideal height at which to fire at the player and the other returns ‘true’ if the weapon is likely to hit the player if fired. These can both be overridden in the subclass to provide more weapon-specific logic. This architecture works great – enemies with shotguns are pretty deadly now and I’ll easily be able to extend to different weapon types to make enemies automatically change their behaviour based on which weapon they are carrying.

Last touch was to design some audio for the shotgun blast. I was going to leave any additional audio and do it all in one batch but seeing that shotgun fired and not make a sound was disturbing me!

Dev Time: 2.5 days
Total Dev Time: approx 62 days

previous | next

mockup_3x
Almost There With The Particle FX

mockup_3x
Working On Collision Detection

mockup_3x
Damn – Shotgun Blasts Shouldn’t Work Through Buildings

Advertisements

Jetboard Joust Devlog #43 – You Bastard!

The next enemy is the last from Defender I need to (loosely) implement. The Defender version is called the ‘baiter’, a small UFO that appears if you take too long to complete a level and gives you all kinds of grief. My version is similarly evil so I’m calling it simply ‘The Bastard’ – because it’s a bit of a bastard.

I thought I’d keep a ‘flying saucer’ aspect to the character design so we have a little alien dude piloting a UFO. It didn’t take me too long to get the basic design sorted but the animation was a bit of a pain. The little spinning antennae at the bottom of the UFO needed to animate at a different rate to the rotation of the UFO itself which meant I needed to split the enemy into two different sprites. Then I thought the pilot looked a bit static and I should try and animate him simply so it looked like he was flipping various controls to steer the craft – this looked rubbish on a loop so I split this out into yet another separate sprite and chose the animation frame randomly rather running on a sequence. It also animates a lot slower than the craft itself. Final touch was to add some particles for an ‘anti-gravity’ type effect.

I could base the motion heavily on the motion for the ‘mother‘ which is one of the reasons this enemy was fairly quick to implement. Every 10 frames the ‘bastard’ samples the player’s location and moves towards it. It’s much faster than the ‘mother‘ and the sampling rate is more frequent which makes it a lot more dangerous! To add a slightly more erratic feel I skip the sampling of the player’s location every three iterations or so.

This straightforward AI worked pretty well but I wasn’t happy with the way the enemy sometimes hovered over the player. I improved this by making the enemy ‘retreat’ when it collided with the player or fired a bullet. It alternates the retreat by flying to the top right, top left or directly above the player. This attack/retreat motion, whilst still pretty ‘dumb’, looked considerably more ‘intelligent’ than simply ramming the player the whole time.

The ‘bastard’ is pretty dangerous – maybe too dangerous. Now I’ve got a few different enemy types in place I think I’m going to have to start working on different weapons and the weapon upgrade system so I can see how these enemies play out against a more powerful opponent. The ‘pistol’ I’ve implemented so far is to be the most underpowered weapon in the game after all.

Dev Time: 1 day
Total Dev Time: approx 59.5 days

previous | next


The Main Character Design – Actually Three Separate Sprites!

mockup_3x
First Draft Of Enemy Motion – A Bit Clumsy

mockup_3x
Adding Attack/Retreat Behaviour. Much Nicer!

Jetboard Joust Devlog #42 – Evil Mothers

Another new enemy in the bag – this one’s called the ‘mother’! At least that’s what I’m referring to it as now anyway.

As with the previous enemy it’s heavily inspired by one of the enemies from the original Defender, in this case the ‘pod’. The main ‘selling point’ of the pod is that when it’s destroyed it releases a bunch of smaller, faster enemies called ‘swarmers’ that use kamikaze tactics to attack the player.

The ‘mother’ works in pretty much the same way. As I’m going for a more ‘character’ based approach to most of my enemies I thought it would be nice to have the original enemy split in to smaller ‘mini me’ versions of itself when destroyed – a kind of mother/child thing.

For the design of the enemy I went for a kind of insectoid ‘space invader’ type approach. It’s consistent with the design of the ‘mutant’ enemy and also I knew I could get this to work at a very small size for the ‘children’. Strangely the hardest thing to get right here was the eyes which I wanted to look like a cross between real eyes and some kind of electronic ‘scanner’ – as though the eyes are on an LED screen or something with a lot of interference.

I’ve made the ‘mother’ probably a bit more dangerous in its original incarnation than the Defender ‘pod’. The AI tracks the player in ‘bursts’ similar to the ‘bomber’ enemy but not restricted to either purely horizontal or vertical movement. It uses a similar simple technique to avoid getting stuck in between buildings as well, ie when it collides with a building it will move upwards until above the level of the building. It also fires slow-moving bullets.

The ‘children’ were basically an extension of the ‘mother’ class with different motion parameters so, thankfully, it didn’t take long to get these up and running at all. I added particle effects to both, a kind of anti-gravity field or something. Note how these get disturbed when the enemy collides with a building or takes damage!

I spent quite a while tweaking the motion parameters of both mother and children, both to get them to feel right in relation to each other and also to get the children to feel like they were moving in a ‘swarm’ without working too obviously in unison. The actual ‘birth’ sequence to a while to get right as well, it needs to be slow enough to see what’s going on yet fast enough to feel like the children are being propelled out as speed. I also added some particles to the birth sequence to give is some more ‘pazazz’. Needs audio too..

Dev Time: 2 days
Total Dev Time: approx 58.5 days

previous | next

mockup_3x
Original Enemy Design – Mother & Children

mockup_3x
Adding Motion And Particles To The Mother

mockup_3x
The ‘Birth’ Sequence

Jetboard Joust Devlog #41 – Bombs Away

Really glad to be working on some new enemy types after wading through what seemed like an endless sludge of audio design and bugfixes! Feels like I’m finally making proper progress again.

I’m calling this enemy the ‘bomber’ – very much inspired by its namesake in Defender of course. I started by designing an enemy that was visually similar to the Defender bomber, a kind of robotic cube thing, but just couldn’t get anywhere with this. It seemed too devoid of personality compared to the other enemies in the game. I then tried designing a more humanoid robot with a jetpack but couldn’t get this to work within the restricted colour palette and resolution either. A fairly frustrating start.

Eventually I thought I’d try something with wings, I was originally thinking of a cross between a robot and a WW2 bomber, kind of like the planes in 1942, but as I started drawing it morphed into this sort of robotic angel which I liked – it reminds me of Antony Gormley’s ‘Angel Of The North‘. Added some particles too of course!

I wanted to keep the AI as simple as possible so settled on a simple algorithm that moves in alternate horizontal and vertical bursts towards the player. If contact is made with a building the sprite moves upwards until it is above the level of the building, thus freeing it to move left and right.

Surprisingly this straightforward algorithm worked OK, I was afraid the enemy would get stuck in endless loops against buildings if the player remained stationary and it did – but this was easily resolved by adding some randomness to the amount of movement in each ‘burst’.

The bomber drops bombs in its stationary phase between each burst of movement. The bombs are actually more like mines in that they float in the same place rather than fall to the floor – I added a small amount of oscillation to make the floating more interesting and a ‘warning’ vibration before the bomb detonates.

And that was pretty much it – there’s a few more subtle things going on like the damage inflicted by a bomb being proportional to how far the player is away from it but I won’t bore you with too many details. Now on to the next enemy…

Dev Time: 2 days
Total Dev Time: approx 56.5 days

previous | next


Probably The Final Bomber Animation


Planting Bombs – Still Looking A Bit Static


Making The Bombs Interact With The Player

Jetboard Joust Devlog #40 – Bits and Bugs

Tidying up some loose ends that were annoying me before I can (finally!) start work on some new enemy types!

1. Fixed ‘Invisible JetBoard’ Bug
If the player destroyed an enemy whilst it was teleporting in the enemy’s jetboard would remain static and invisible in the world. Fixed this so that a teleporting enemy’s jetboard drops down properly.

2. Cropped Jetboard Bug
This one had been ‘bugging’ (groan) me for some time, it appeared that enemy jetboards were getting randomly cropped on occasion for no apparent reason. Turned out that it was a crop at all but the board wasn’t always orientating correctly when the enemy changed direction.

3. Particles Going Weird On Level Exit
You can see this issue at the end of the video here. To get the level transform effect I render the entire world to a back buffer and then apply a custom shader when rendering to screen – turns out that optimisations I made to my particle system meant I was rendering direct to screen all the time and ignoring the back buffer (oops).

4. Various ‘End Of Life’ Bugs
There were various problems to do with a player getting killed when already dead and controls still operating the jetboard when the player was dead – these were largely to do with the fact that enemies continue shooting at the player even when he’s already dead ‘just to make sure’. I like this though, it’s funny, so I kept it and fixed the bugs.

5. Disallow Enemy Abductions/Mutations When Player Dead
Not really a ‘bug’ per se but I didn’t like the fact that enemies could carry on abducting babies and mutating when the player couldn’t do anything about it – it didn’t seem ‘fair’ somehow. Now they just hover when the player is in the ‘lost life’ state which, though it doesn’t make logical sense, seem to work from a gameplay perspective.

6. Add Floating Scores
I just like these and nearly always put them in my games – something very old school arcade’ about them.

7. Improve AI In Small Gaps
Enemies were doing some pretty stupid things when the player took cover in a gap between two buildings. This was the result of an algorithm I wrote to calculate the closest building to the player which didn’t work properly, and part of the AI which tries to move away from the player if overlapping (ie avoid ‘kamikaze’ style behaviour). Now, when in a small gap, the enemy should move to the edge of the building that’s furthest from the player, turn around and start firing. It’s tricky to get this stuff right and fixing this took a while!

8. Improve Message Font
This was probably the bulk of the work. Previous in-game messages appeared on the scanner – I didn’t like this for two reasons; it got in the way of the action on the scanner and it necessitated the use of a very small font which made the messages unclear. Double fail. I have moved messages to the main game area which seems to work OK, designed a custom bitmap font for them based on the font I’m using for the HUD (but smaller), and also added ‘impact shader’ effects. Still a bit worried about them getting in the way of the action but actually it seems to work OK (I tried placing them over the ‘ground’ at the bottom of the screen as well but this didn’t seem to work so well).

Dev Time: 2.5 days
Total Dev Time: approx 54.5 days

previous

mockup_3x
Enemies Now Act More Sensibly In Small Gaps

mockup_3x
Added Floating Scores When Enemies Are Destroyed

mockup_3x
Designing A Custom Bitmap Font For In-Game Messages

mockup_3x
Adding Impact Effects To In-Game Messages