diff options
Diffstat (limited to 'congrats_animation.c')
-rw-r--r-- | congrats_animation.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/congrats_animation.c b/congrats_animation.c index 34a1905..67c3d0b 100644 --- a/congrats_animation.c +++ b/congrats_animation.c @@ -1,19 +1,31 @@ #include <stdio.h> +#include <time.h> #include <unistd.h> #define DISTANCE 10 #define DOWNTIME 100000 int main(){ int i, j; + int num_rand; //for random color + int counter = 1; //change color when hits 5 + + srand(time(NULL)); while(1){ for(i = 0; i < DISTANCE; i++){ + counter++; + for(j = 0; j < 15+i+1; j++){ printf("\b \b"); //backspace } for(j = 0; j < i; j++){ printf(" "); } + if(counter == 5){ + num_rand = (rand() % 7) + 1; + printf("\e[0;3%dm", num_rand); + counter = 1; + } printf("Congratulations"); fflush(stdout); usleep(DOWNTIME); |