From ff323cdde3148a51321685e353a40a270f7795ea Mon Sep 17 00:00:00 2001 From: loshprung Date: Thu, 27 Feb 2020 18:59:22 -0800 Subject: added basic color changing --- congrats_animation.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'congrats_animation.c') 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 +#include #include #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); -- cgit