Randomize explosion thinktime.

This gives engine trails and explosions a more natural look.
This commit is contained in:
Guus Sliepen 2011-08-24 23:08:48 +02:00
parent 9e32c230be
commit 5be6a5ec7d
1 changed files with 12 additions and 9 deletions

View File

@ -76,24 +76,27 @@ void doExplosions()
if (explosion->active == 1) if (explosion->active == 1)
{ {
explosion->thinktime--;
explosion->x += engine.ssx; explosion->x += engine.ssx;
explosion->y += engine.ssy; explosion->y += engine.ssy;
if (isOnScreen((int)explosion->x, (int)explosion->y, explosion->image[0]->w, explosion->image[0]->h)) if (isOnScreen((int)explosion->x, (int)explosion->y, explosion->image[0]->w, explosion->image[0]->h))
graphics.blit(explosion->image[0], (int)explosion->x, (int)explosion->y); graphics.blit(explosion->image[0], (int)explosion->x, (int)explosion->y);
if (explosion->thinktime < 1) if(rand() % 7 == 0)
{
explosion->thinktime -= 7;
if(explosion->thinktime < 1)
{ {
explosion->active = 0; explosion->active = 0;
} }
else if (explosion->thinktime % 7 == 0) else
{ {
explosion->face++; explosion->face++;
explosion->image[0] = graphics.shape[explosion->face]; explosion->image[0] = graphics.shape[explosion->face];
} }
} }
}
if (explosion->active == 1) if (explosion->active == 1)
{ {