diff options
author | loshprung <lshprung@scu.edu> | 2020-02-27 18:59:22 -0800 |
---|---|---|
committer | loshprung <lshprung@scu.edu> | 2020-02-27 18:59:22 -0800 |
commit | ff323cdde3148a51321685e353a40a270f7795ea (patch) | |
tree | c0b7e82092b15becbf57529fc9573ff4945dbf0f /congrats_animation.c | |
parent | 28425a3b9177749b2650a5e9c70043287a58f5bc (diff) |
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); |