Ok, first off it’s been a week since I posted. Honestly, I didn’t have anything to post. I was busy crushing bugs in my space shooter. I really already touched on everything I had added, it was just the boring part (or exciting, depending on how you look at it) — fixing the little things.
Things like this:
6 days. It’s been 6, long, days since I posted my last article. Why? Because I sunk my teeth into the boss wave in my 2D Space Shooter. Wow, this was a lot of work.
The thing is, as I made the boss wave for some reason it started to create havoc on my other code. I still to this point don’t know why. Things stopped working, things disappeared, pure chaos.
At one point, my boss wave looked like this:
Ok I’m coming clean right from the start. This challenge really threw me for a loop. I’m not sure if it has to do with the pages of code I already have in this game or if it’s time for me to move on to another game. But man, this took forever! I want to give a big shoutout to my colleague Connor Fullarton who wrote this article to get me over the hump!
So, what threw me for such a loop? Giving the player the ability to press the C key and have powerups come to him. …
We’ve given 6 powerups to the player to help him combat enemy AI. So what happens if we take it away? What happens if the enemy, who I might add is growing smarter every article I write, decides that it can “see” the powerups? What happens if it can see the powerups AND decide to blow them up?
So that’s what I did. I gave the enemy AI even more brains. Now while it is travelling down it is sending out a “radar” of sorts and if it stumbles across a powerup, BOOM.. it takes it out.
Ok first you may notice a bit of a change to the opening. I’ve added a giant enemy at the top of the screen. I wanted to have something that would kick off the fight. So I thought why not have an out of control enemy get destroyed and then the waves come after the player for doing so. The gif you see was just me adding the new enemy but the spawning won’t actually start until I destroy the big ship. See below:
Ok, so we have our enemy AI moving in random directions and shields to help protect them. Now it’s time to give them a brain.
Let’s make it so a random enemy will have the will to kamikaze the player.
To do this I need to change the enemy movement code only slightly. I can leave the same movement code that I have orginally and just another function and case to the code.
This is placed inside the enemy script. First I’m going to be using the physics engine provided by Unity and MovePosition that will give the object momentum…
So today I’m going to be giving our enemy AI some shields. I’ve chosen to just give it randomly — 25% chance that when instantiated the enemy will come with a shield. It’s just a 1 shot shield but when there are a lot of enemies on screen it really increases the challenge.
First I just grabbed the player shield sprite and changed the color of it to give the enemy a different look.
So I’ve added a lot of things to this Space Shooter including 6 powerups and 1 powerdown. Now it’s time to get some balance. At the moment I have 2 of the items using their own script to give some weighted balance. The missiles and the powerdown, so I won’t include them in this new balance. I’m happy with how they are spawning.
You could do that actually, just set a whole script onto a powerup that will calculate a random number and use that to spawn. But that isn’t going to really balance anything and it’s also a little…
So last time we made the player have to think a little by adding a PowerDown that causes his movement to slow down by half. This time, we are going to add an extra enemy — a bomber.
I found a cool bomber looking spaceship and a bomb online and added them to my sprite list. I am going to use the explosion animation and sound when the bomber is hit.
This wasn’t at all that difficult to be honest. Once you have a lot of your code done it’s just adding a line here or there.
To start I…
This was a fun challenge. Giving the player a reverse powerup that would inhibit his ability to kill my precious AI enemies!
I thought long and hard about this one… I was going to create a powerup that looked like a normal powerup and if they ran into that thinking they were getting speed they would get this. But I thought maybe a spawning powerup that the player could run into by accident. Sometimes having to choose between taking a laser or the powerup. I chose the second.What I wanted to do was when the player collided with this new…