Wednesday, March 28, 2007

Weapons are nearing completion

So, I got most of the weaponry in. I got a Weapon class to fire projectiles(Perhaps I have to add some more classes, such as a BulletWeapon and MissileWeapon, but not right now). The projectiles are in aswell, and this includes bullets and missiles(Which happen to be the only projectiles in the game). Also, the death hand missile is in, including 3x3 explosions.

I took a different way for missile weapons that the original. In the original there were 16 images of the missiles, where each image was rotated 22.5 degrees. Since the original had to run on 8 to 16 Mhz machines, rotating the images in real-time was probably impossible, so they just had a bunch of pre-made images. In assume they used a Cos/Sin lookup table during the game to calculate the trajectory of the missiles, since Cos/Sin calls are pretty expensive.

However, I wanted to save myself the hassle of having to calculate which of the images I had to use, so I cut up the images, took the 0 degree image, enlarged it and use that myself.

I did run into some serious trouble with the rotation tho. At first, I couldn't figure out how to rotate the 2D image without upsetting the entire world view. Turns out I forgot to restore the original Transform. Oops. And, I didn't quite understand that I needed to take the negative value of atan2() when the adjacent side of the triangle is below 0. Took me all day long to debug. But it works now.

As promised: The image. It shows randomly launched Death Hand missiles flying to their destination and explode. Oh, and a lone tank which I used to test the bullet and missile weapons on.


The next step is for weapons to have some intelligence: They have to determine if their target is in range, and if not, don't fire. After that, I can actually implement inflicting some damage based on armor stats. If that's all working, I can do some testing, and implement unit squashing. Oh, and corpses.

3 comments:

Anonymous said...

Nice. So you rotate the sprite itself instead of using the pre-made 'faces' of a bullet?

This will not work on c&c like games then though ;-)

Nice, have weapons as intelligence. I suppose you mean 'properties' , ie a rocket launcher can launch a missile on x range. Perhaps you can even think of moving it to unit intelligence. Where you just specify to a weapon a destination. the unit itself will then determine if something is in range?

Toolmaker said...

Well, weapons don't have much intelligence.

I phrased myself a bit wrong. Right now, the weapon class has a IsInRange(start, end) which determines if a weapon is in range. And it has a Fire() which determines wether or not the weapon can shoot, and if it does, it launches a projectile. That's all the intelligence the weapns have :)

Fundynamic - Stefan Hendriks said...

Sounds good. Odd, previous post was Anonymous, yet it was me ;-)

Anyway.

Nothing to add further. Keep on going.