Skip to content

Instantly share code, notes, and snippets.

@ViKingIX
Created November 20, 2015 01:33
Show Gist options
  • Save ViKingIX/a1ba36961b6602d2a246 to your computer and use it in GitHub Desktop.
Save ViKingIX/a1ba36961b6602d2a246 to your computer and use it in GitHub Desktop.
matrix like message display animation
void scr_about_init(void)
{
w_about = newwin_title(0, WAV_HEIGHT, "About", false);
for (i = 0; i < ARRAY_SIZE(about_lines); i++) {
linecd[i] = malloc(strlen(about_lines[i]) * sizeof(int));
for (j = 0; j < strlen(about_lines[i]); j++)
linecd[i][j] = (rand() / (float)RAND_MAX) * 120 + 60;
}
}
int scr_about_loop(WINDOW *w_menu)
{
char buf[0x100];
for (i = 0; i < ARRAY_SIZE(about_lines); i++) {
for (j = 0; j < strlen(about_lines[i]); j++) {
if (linecd[i][j] > 60) {
buf[j] = ' ';
linecd[i][j]--;
} else if (linecd[i][j]) {
buf[j] = (rand() / (float)RAND_MAX) * 54 + 65;
linecd[i][j]--;
} else {
buf[j] = about_lines[i][j];
}
}
buf[j] = '\0';
waddstr_center(w_about, (WAV_HEIGHT - ARRAY_SIZE(about_lines))/2 + i, buf);
}
wrefresh(w_about);
return wgetch(w_menu);
}
void scr_about_fini(void)
{
delwin(w_about);
for (i = 0; i < ARRAY_SIZE(about_lines); i++)
free(linecd[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment