CodeBase - variable bullet code

Return to the CodeBase listing

Category: 3D

Version: 1.0

0
0

Information

Uploaded: 23rd Oct 2005 14:15

Modified: 1st Jan 1970 01:00

Author:  Visigoth

Summary

Bullet code to generate bullets that can fire at variable speeds and rate of fire. Uses a type for bullets and vectors for timing

Full Description

I am creating a game that simulates airsoft(bb guns, basically), so I needed a bullet code that would allow me to change rate of fire and speed easily, as well as other variables, like weight of bb, color, size, etc. After a bunch of tries, I came up with this. Firstly, I create a bullet type that stores all the data about the bullet. Then, I create an array that stores the bullet type. The actual shooting part is where it gets a little tricky. First, after you click the mouse button, the prog checks to see if the bullet is alive, and if so, it fires the bullet. The timing is done using vectors. The second bullet isn't fired until the first bullet travels X amount of distance. By changing this distance, the rate of fire can be changed. Alos, by changing the speed field in the bullet type changes the velocity of the bullet. I can easily implement this into a game to allow for different gun types, just by creating bullet types for different guns, or, by changing the field values during run time when you use different guns. Problems still to be worked out: collision. Collision before the bullet travels X distance. Aiming. But, this should all be doable.

Comments

No comments yet.