Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define WIDTH 250
- inline int prob(int n) {
- switch (n) {
- case 2: return 20;
- case 1: return 10;
- default: return 20;
- }
- }
- int main() {
- unsigned char cols[WIDTH];
- int i, j;
- struct timespec t;
- srand(time(NULL));
- t.tv_sec = 0;
- t.tv_nsec = 5e7L;
- fputs("\033[38;5;82m", stdout);
- for (i=0; i<WIDTH; i++)
- cols[i] = rand()%3;
- while (1) {
- for (i=0; i<WIDTH; i++) {
- j = cols[i];
- if (j == 2) fputs("\033[38;5;82m", stdout);
- else if (j) fputs("\033[38;5;28m", stdout);
- else fputs("\033[30m", stdout);
- putchar(32+rand()%(126-32));
- if (!(rand()%prob(j))) cols[i] = (j+2)%3;
- }
- fflush(stdout);
- nanosleep(&t, NULL);
- putchar('\n');
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment