Added jumble effect

modified:   src/nms.c
This commit is contained in:
Brian Barto 2016-04-10 15:51:05 -04:00
parent dd89bbc721
commit e8d708a353

View File

@ -28,13 +28,14 @@ int main(void) {
struct winpos *temp; // Used for free()ing the list struct winpos *temp; // Used for free()ing the list
int termSizeRows = getTermSizeRows(); int termSizeRows = getTermSizeRows();
int termSizeCols = getTermSizeCols(); int termSizeCols = getTermSizeCols();
int c, x = 1, y = 1;
int ms, ls;
bool first = true;
// Seed my random number generator with the current time // Seed my random number generator with the current time
srand(time(NULL)); srand(time(NULL));
// Geting input // Geting input
int c, x = 1, y = 1;
bool first = true;
while ((c = getchar()) != EOF) { while ((c = getchar()) != EOF) {
if (c == NEWLINE) { if (c == NEWLINE) {
++y; ++y;
@ -63,14 +64,34 @@ int main(void) {
clearTermWindow(termSizeRows, termSizeCols); clearTermWindow(termSizeRows, termSizeCols);
// Printing the list // TODO: pause with getchar() - something about the input stream being redirected
// to a file is causing getchar() to immediately return here.
// Jumble loop
ms = 35; // miliseconds, used for usleep()
ls = 2; // loop seconds, number of seconds to loop
x = 0;
while (x < (ls * 1000) / ms) {
list_pointer = start; list_pointer = start;
while (list_pointer != NULL) { while (list_pointer != NULL) {
printf("\033[%i;%iH%c", list_pointer->row, list_pointer->col, list_pointer->mask); printf("\033[%i;%iH%c", list_pointer->row, list_pointer->col, list_pointer->mask);
list_pointer->mask = getMaskChar();
list_pointer = list_pointer->next; list_pointer = list_pointer->next;
} }
usleep(ms * 1000);
++x;
}
printf("\n"); printf("\n");
/*
// Reveal loop
x = 0;
while (x < 50) {
++x;
}
*/
// Freeing the list. // Freeing the list.
list_pointer = start; list_pointer = start;
while (list_pointer != NULL) { while (list_pointer != NULL) {