I\'m running into a snag here as far as the enemy.Basically I\'m working on a vertical shooter.I thought I would start simple first.The enemy would be created randomly somewhere at the top of the page.The plane would move straight downward.As it\'s flying down it will fire a bullet straight down from it\'s location.
The last part is the part I\'m having trouble with.Right now the code will produce a bullet from one plane and then after that nothing.If I put the function in the game loop section then each plane will produce a flickering bullet that will not go anywhere.I\'m not sure how to get it to do what I want it to do..But here is the relevant code that I have so far.
enemy.h- controls the creation and behavior of my enemies
void enemy()
{
// in this loop we\'re going to create our enemy sprites
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++)
{
int fire = dbRnd(100); //set a random value to fire
if(fire >50) //if fire is greater than 50
{
for(int j = 10; j < 15; j++)
{
//Create Bullets at the sprite
dbSprite(j,dbSpriteX(i), dbSpriteY(i),4);
}
}
}
}
void border()
{
for(int i =5; i <9; i++)
{ //if our enemy goes past 600
if(dbSpriteY(i) > 600)
{
//reposition him at a random location up top
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
dbScaleSprite(i,50);
}
}
}
The enemyFire() function is where I believe the majority of the problem is.But I honestly can\'t figure out what I might do to fix it.Any suggestions would be welcome
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.