Sunday, January 17, 2010

Bullet firing and Rotation

Well i got the first pass on Enemy Bullets today.

I think they look pretty sweet. I have always had a fondness for odd shaped bullets, the reason is they look so much more interesting and to me, more intimidating. So i made some that are Egg shaped, or at least oval. Then put them in the game. Of course my first basic bullet type is the trajectory bullet. Initially i used a straight Delta value and then normalized it and multiplied it up to the speed i want for my bullets. But i found that sometimes they go at faster or slower speeds, depending on how close i am to the enemy that fires them. I am not sure exactly why from a math standpoint, but what the hay, i just rewrote the code anyway.

This time i wrote it to be a system i have used before and one i know very very well after all these years. I grabbed the target delta and then used a sin/cos combination from the angle to produce a trajectory velocity pair. This works so well and is hugely accurate.

Then i got to writing the spinning sprite code, to show off that egg shaped bullet better. Once i got it spinning i had to center it on the sprite, this though was odd, because now the detection was offset, bah! there is always some hurdle to overcome. Anyway with some minor fiddling i set the center up correctly and then moved the sprite to the place it should be drawn from. This fixed the collision and also the rotation.

So why make odd shaped bullets? the reason is not just i think it looks more intimidating, but it is one of those little attention to detail items that sets better quality games from cheaper games. It would have ben much faster to make round bullets of course. I recommend that anyone writing games tries hard to put in such details. They can make all the difference when added together.

No comments:

Post a Comment