Just wanted to let everyone know that I figured out the problem as far as recycling the planes.I have left some of the relevant bits here for anyone that might be working on the same problem.Maybe it might help some.
enemy.h - controls the apperance and behavior of my enemy
void enemy()
{
// in this loop we're going to create some animated sprites, the image
// we load contains frames of animation for an asteroid
for ( int i = 5; i < 9; i++ )
{
dbLoadImage ("enemy.bmp", i );
// position our sprite at a random location
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
dbScaleSprite(i,50);
}
}
void enemyFire()
{
for (int i =5; i <9; i++)
{ // we use this to check each enemy sprite
int fire = dbRnd(100); //pick a random number 1-100
if( fire > 50) //if fire is greater than 50
{ //create the bullets
for(int j = 10; j < 15; j++)
{ //then fire them from the enemies locale
dbSprite(j,dbSpriteX(i), dbSpriteY(i),4);
}
}
}
}
moving.h - involves the movement of bullets, the player and collision between the various objects..
void moving()
{
if(dbLeftKey() == 1) //If Left key is pressed
{
dbRotateSprite(2,90);
dbMoveSprite(2,-3);
dbRotateSprite(2,0);
}
if(dbRightKey() == 1) //If Right key has been pressed
{
dbRotateSprite(2,90);
dbMoveSprite(2,3);
dbRotateSprite(2,0);
}
if(dbUpKey() == 1) //If the up key has been pressed
{
dbMoveSprite(2,3);
}
if(dbDownKey() == 1) //If the Down Key has been pressed
{
dbMoveSprite(2,-3);
}
dbMoveSprite(3,5); //Move our bullet up the screen
for ( int i = 5; i < 9; i++ )
{
dbMoveSprite(i,-3); //move our enemy sprite down the screen
}
for(int j = 10; j < 15; j++)
{
dbMoveSprite(j, -5); //Move our enemy bullets down the screen
}
}
void collision()
{
for(int i =5; i <9; i++)
{
if(dbSpriteCollision(3,i))
{ //if the bullet collidea with the enemy
dbDeleteSprite(3); //delete bullet
dbDeleteSprite(i); //delete enemy
//reposition enemy at top of screen
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
dbScaleSprite(i,50); // resize the sprite to half
}
}
}
void shooting()
{
if(dbSpriteCollision(3,0) == 0) //If the bullet isn't collising with anything
{
if(dbSpaceKey() ==1) //If the shift key is being pressed
{
dbStopSound(2);
dbSprite(3,dbSpriteX(2)+ 25,dbSpriteY(2)+ 25,3);
dbPlaySound(2); //create gun sound
}
}
}
void border()
{
for(int i =5; i <9; i++) //cycle through enemy sprites
{
if(dbSpriteY(i) > 600) //if location of the sprites is
{ //greater than the screen height
//reposition the enemy sprite
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
dbScaleSprite(i,50); //scale it to half size
}
}
}
It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.