I seem to be having trouble with timers.I have two problems but I think they stem from the same source.So If I figure out how to solve one then I think I will be able to solve the other.Well I was working on collision.I'm trying to make it where if my player plane hits a enemy plane they are both destroyed.That part works great.The problem comes in bringing them back.I wanted to make it where after a couple of seconds the player plane would come back.I decided to try to try to make a timer out of two variables. same trick they used in the dark invaders example.But it isn't working for me.Trying to figure out what I did wrong.I put the whole collision function here but I believe I commented well.
void collision()
{
for(int i =5; i <9; i++)
{
if(dbSpriteCollision(3,i))
{
dbDeleteSprite(3); //delete bullet
dbSprite(20,dbSpriteX(i), dbSpriteY(i),20); //start the explosion sprite at the enemies location
dbDeleteSprite(i); //delete enemy planes
dbPlaySound(3); //Let's hear the explosion
score++;
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i ); //reposition enemy plane at top of screen
dbScaleSprite(i,50); //make them half the original image size
}
if(dbSpriteCollision(2,i)) // if the player collides with a plane
{
dbDeleteSprite(i);
dbHideSprite(2); //Hide the player sprite
dbPlaySound(3); //Let's hear an explsosion
//have to figure out how to make the game wait for a little while before showing the plane again
showPlayerDelay++;
if(showPlayerDelay >2)
{
playerReturns++;
showPlayerDelay = 0;
}
if (playerReturns == 3)
{
dbShowSprite(2);
}
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i ); //reposition enemy plane at top of screen
dbScaleSprite(i,50); //make them half the original image 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.