Thursday, December 2, 2010

A Cool Bug

Alot of people think that bugs in software are serious issues that ruin and cause destruction everywhere they go.
I, however, like to classify bugs into 2 different groups.

1) Cool
2) Not Cool

The "Not Cool" kinds of bugs are ALOT more common.


Those "Not Cool" bugs are stupid. EVERYONE hates them.


They will come at you from stupid obvious "noob" typos and
They come at you from the most obscure places.

Sometimes they cause your game to act retarted.
And other times (and more common) they will simply trip your game and leave you to read a large blob of (in my case red) text that your interpreter vomits back out at you after choking on a large piece of useless stuff.

But thats the sad side of bugs.

And to keep things interesting i decided that this post im going to be talking about the "Cool" side.

They are not very common. In fact, im pretty sure ive only ever had, something like 3 of them in my entire programming history.
One of them made me laugh in public, one was so cool that i had to keep it in my game, and the last one (which i came across today) caused me to struggle between looking into its frustrating cause, and marvel at its awesomeness.

Bug #1
The first one came when i was trying to program an enemy to chase me around the screen.
This was during my first graphical project so i was a total know nothing head. At the time, I had no knowledge of vectors, so the movement of my enemy was super basic. The main issue was that every frame, the enemy would move up to your same x position. But if the enemy had a greater speed than the distance from your x position to his, then he would jump past you to the other side.

If i was 5 above the enemy, then the enemy would be told to move up.
So lets say the enemy had a speed of 10.
when the enemy moves up, he is now going to go from 5 BELLOW me to 5 ABOVE me.
and the next frame the enemy would be in the same position as before, just on the opposite side.
This would cause a crazy effect where the enemy would spaz out and move up and down super super fast (30 times a second).
So this whole thing was confusing me greatly and i had no clue why the enemy was being a spaz. So i decided to turn up the movement speed and see what would happen. I put it to something like 300 and then when i ran it i had this blur of color flying from one side of the screen to the other very fast.

And also the enemy would kill me in one hit.

so there i was, trying to frantically stop any contact from an enemy who darted across the screen 30 times per second. It was crazy, unexpected, and (to me) very funny.

I happend to think it was so funny that i started laughing in the middle of math class and everyone started looking at me all wierd. Needless to say, that quick blur soon killed me, and i was left with no other options but to turn down the movement speed and get on with my life.

Bug # 2
this one involved a new tower that i was working on for my tower defense game called the homing tower. It would shoot an orb that would follow the target until it made contact. The orb would then explode and damage the target.

I had the homing towers working for awhile when i happened to be messing with something and the collisions got disabled with the orbs and the enemies. This caused a (really) cool bug where the orb would fly to the enemy and pass right through, then turn around and go right back towards it. This one is very similar to Bug #1but a whole lot cooler.

So i was sitting there watching this awesome thing zig and zag its way around the enemy desperately trying to register some kind of collision that would end its meaningless existence. But I knew the collision would never come, and i also knew that this sporadic orb looked a whole lot like a fly. Which is when I thought something like: "Whoah!! thats awesome!! im gonna turn that into its own tower!"

Which is exactly what i did.

Bug # 3
This one was really cool, but not really feasible as an actual tower.
It happened when i was working on my new beam towers. In order to get their new attack type working, I had to change a bunch of general ways that attacks and targeting was handled.

After i got them working, I then tested the orbital towers again.

They didnt work.

So after fixing some of those "Not Cool" bugs, they were working again, but not the way that i was expecting.

The thing about the orbital towers is that the target of their shots is actually the tower itself. It constantly circles around the tower and tries to get down to its center (which some programming of their velocity and stuff has made sure) will never happen. Even though their target is the center, I have made it so anytime they hit an enemy, they will do damage.

So due to some label and naming errors, for some reason the target was not the actual tower, but became the nearest enemy they could find. This created a sort of cool effect because all of a sudden the shot would orbit around a moving enemy and it would move in more of a cork screw pattern instead of a real orbit.

This one took me a while to figure out the issue. and I would love to keep a tower like that in my game but it really cant hit anything. So until i can find a way to make it useful i guess i will just have to tell stories about it.

There you go, my 3 different "Cool" bugs.

wow this post is really long.
1051 words to be exact
thanks and have a nice day.

1 comment:

  1. Great post! I love how it was both technical and very entertaining. Nice job!