From 9497cdd0d6d1483f559aacf3f8f2bbb6a11716ab Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Fri, 30 Aug 2024 12:03:32 -0500 Subject: Create seizure inducing winning anim --- src/screen.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- src/screen.h | 27 ++++++++++++++++----------- 2 files changed, 60 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/screen.c b/src/screen.c index fa5bb28..5fe2822 100644 --- a/src/screen.c +++ b/src/screen.c @@ -175,6 +175,9 @@ static int docolors(void) { init_rgb_color(CC_WHITE, 255, 255, 255); init_rgb_color(CC_BLACK, 0, 0, 0); + init_rgb_color(CC_WINNING, 232, 185, 35); + + init_pair(CCP_TESTING, CC_RED, CC_WHITE); init_pair(CCP_BANNER, CC_WHITE, CURSES_BLUE); @@ -186,6 +189,9 @@ static int docolors(void) { init_pair(CCP_PURPLE, CC_WHITE, CC_PURPLE); init_pair(CCP_MAGENTA, CC_WHITE, CC_MAGENTA); init_pair(CCP_WHITE, CC_BLACK, CC_WHITE); + + init_pair(CCP_WINNING1, CC_WHITE, CC_WINNING); + init_pair(CCP_WINNING2, CC_WINNING, CC_WHITE); } else { endwin(); error(1, ENOTSUP, "[VX-GAMBLEGROUND] Colors are not supported on your terminal"); @@ -449,10 +455,16 @@ int spin(void *params) { /* Previous solution fucked it by changing the actual color when it's supposed to be the default color to revert back to // This works better, but is also more ugly. So be it */ wbkgd(p->slots->subslot[subs], COLOR_PAIR(rangemod(CCP_CURSES_DEFAULT, i + CCP_RED, CCP_RED, CCP_WHITE))); - + + #ifndef TESTING p->slots->slotchar[subs][2] = p->slots->slotchar[subs][1]; p->slots->slotchar[subs][1] = p->slots->slotchar[subs][0]; p->slots->slotchar[subs][0] = randombytes_uniform('~' - '!' + 1) + '!'; + #endif + + #ifdef TESTING + p->slots->slotchar[subs][1] = '7'; + #endif // Update characters & draw them int my, mx; @@ -468,6 +480,37 @@ int spin(void *params) { nanosleep(&sleeper, NULL); } + // Check to see if user has won a jackpot + int winning = 0; + for(size_t i = 0; i < STATIC_ARRSIZE(p->slots->subslot); i++) { + if(p->slots->slotchar[i][1] == '7') + winning++; + } + if(winning == 3) { + // Do winning anim + mvaddch(0, 0, 'J'); + for(int i = 0, color = CCP_WINNING1;; i++, color = rangemod(color, 1, CCP_WINNING1, CCP_WINNING2)) { + // wbkgd(p->bannerwin, COLOR_PAIR(color)); + // wbkgd(p->menuholder, COLOR_PAIR(color)); + + // wbkgd(p->slots->slotwin, COLOR_PAIR(rangemod(color, 1, CCP_WINNING1, CCP_WINNING2))); + // for(size_t j = 0; j < STATIC_ARRSIZE(p->slots->subslot); j++) { + // wbkgd(p->slots->subslot[j], COLOR_PAIR(rangemod(color, j + 1, CCP_WINNING1, CCP_WINNING2))); + // wnoutrefresh(p->slots->subslot[j]); + // } + + // wnoutrefresh(p->bannerwin); + // wnoutrefresh(p->menuholder); + // wnoutrefresh(p->slots->slotwin); + + bkgd(COLOR_PAIR(color)); + addch("JACKPOT"[rangemod(i, 1, 0, 6)]); + + refresh(); + nanosleep(&sleeper, NULL); + } + } + // Revert colors back to normal wbkgd(p->bannerwin, COLOR_PAIR(CCP_BANNER)); wnoutrefresh(p->bannerwin); diff --git a/src/screen.h b/src/screen.h index 22211b4..25cd8fa 100644 --- a/src/screen.h +++ b/src/screen.h @@ -41,6 +41,8 @@ enum custom_colors { CC_WHITE, // RGB: 255, 255, 255 CC_BLACK, // RGB: 0, 0, 0 + CC_WINNING, // RGB: 232, 185, 35 + // This isn't actually a color, even if you try to use it as one CC_TOOBIG }; @@ -50,17 +52,20 @@ enum customcolor_pairs { CCP_CURSES_DEFAULT = 0, - CCP_TESTING, - CCP_BANNER, - - CCP_RED, - CCP_ORANGE, - CCP_YELLOW, - CCP_GREEN, - CCP_BLUE, - CCP_PURPLE, - CCP_MAGENTA, - CCP_WHITE, + CCP_TESTING, // Text: White, BG: Red + CCP_BANNER, // Text: White, BG: Curses' Blue + + CCP_RED, // Text: White, BG: Red + CCP_ORANGE, // Text: Black, BG: Orange + CCP_YELLOW, // Text: Black, BG: Yellow + CCP_GREEN, // Text: Black, BG: Green + CCP_BLUE, // Text: White, BG: Blue + CCP_PURPLE, // Text: White, BG: Purple + CCP_MAGENTA, // Text: White, BG: Magenta + CCP_WHITE, // Text: Black, BG: White + + CCP_WINNING1, // Text: White, BG: Gold + CCP_WINNING2, // Text: Gold, BG: White CCP_TOOBIG }; -- cgit v1.2.3