From 5be6a5ec7d55062421f09b5090a0fa537fe1973f Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 24 Aug 2011 23:08:48 +0200 Subject: [PATCH] Randomize explosion thinktime. This gives engine trails and explosions a more natural look. --- code/explosions.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/code/explosions.cpp b/code/explosions.cpp index 9bd670b..0d3f53a 100644 --- a/code/explosions.cpp +++ b/code/explosions.cpp @@ -76,22 +76,25 @@ void doExplosions() if (explosion->active == 1) { - explosion->thinktime--; - explosion->x += engine.ssx; explosion->y += engine.ssy; 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); - if (explosion->thinktime < 1) + if(rand() % 7 == 0) { - explosion->active = 0; - } - else if (explosion->thinktime % 7 == 0) - { - explosion->face++; - explosion->image[0] = graphics.shape[explosion->face]; + explosion->thinktime -= 7; + + if(explosion->thinktime < 1) + { + explosion->active = 0; + } + else + { + explosion->face++; + explosion->image[0] = graphics.shape[explosion->face]; + } } }