you mean, how to know if it is not colliding with any of your objects?
int colliding = 0;
for ( int i = X1; i <= X2; i++ )
{
if ( dbObjectCollision ( bullet, i ) )
collidig = i;
}
here, X1 is the ID of the lowest enemy's ID, X2 is the highest
colliding will get the ID of the object that is colliding with your bullet, if no collision is happening it will be 0.
here, i recommend using vectors, you can read about them on the net ( cplusplus.com maybe ), if you want a code with vectors:
//include
#include <vector>
//namespace
using namespace std;
//make a structure for your objects, including all their data
struct OBJECT
{
int ID; //ID of the object
//you can add whatever you want..e.g.
int health;
bool moving;
bool dead;
};
//okay now make the vector ( i prefer it to be global so you can always access it from anywhere as you will use it alot. )
vector<OBJECT> EnemyV(0); //create empty vector, each element will be of the type OBJECT
//..
//..
//when you load an object ( enemy ) you should define it in the vector, e.g.:
dbLoadObject ( "Enemy.X" 1 );
OBJECT obj;
obj.ID = 1;
//fill other data id you want ( health / dead / moving etc etc.. )
EnemyV.push_back ( obj ); //now the object is defined in the vector
//..
//..in main loop..
//if you want to access it:
for ( int i = 0; i < EnemyV.size(); i++ ) //loop through all vector elements
{
if ( dbObjectCollision ( EnemyV[i].ID, bulletID ) )
{
//object ( ID: EnemyV[i].ID ) is colliding with the bullet, deal with it
}
}
hope that helps