From e02eea72455ffbd3647898b2c65dc5b6626d33b8 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Wed, 28 Aug 2024 16:58:12 -0500 Subject: Random slots achieved --- src/screen.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/screen.c') diff --git a/src/screen.c b/src/screen.c index d6806ad..85bc031 100644 --- a/src/screen.c +++ b/src/screen.c @@ -231,7 +231,8 @@ static int init_slotholder(struct slotholder *slots) { const int height = my - 2, width = mx - 2; mvwcreate_box(slots->subslot[i], 1, 1, height, width, NULL); for(int j = 0; j < 3; j++) { - mvwcreate_box(slots->subslot[i], 2 + (j * (height / 3)), width / 4, height / 3, width / 2, NULL); + slots->slotchar[i][j] = randombytes_uniform('~' - '!' + 1) + '!'; + mvwcreate_box(slots->subslot[i], 2 + (j * (height / 3)), (width / 4) - 1, height / 3, (width / 2) + 5 /*???????????*/, NULL); } wnoutrefresh(slots->subslot[i]); @@ -276,7 +277,7 @@ int main() { struct funcholder *p = NULL; // Function pointer used for callbacks in the menu driver WINDOW *menuholder = NULL; // The window for displaying the menu int row = -1, col = -1; // The rows and columns of the main screen - int randomnum; // A random number for getting the banner phrase + uint32_t randomnum; // A random number for getting the banner phrase MENU *menu; // The actual menu object int c; // Integer for storing keys from user input @@ -289,10 +290,6 @@ int main() { } randomnum = randombytes_uniform(STATIC_ARRSIZE(phrases)); - if(randomnum < 0) { - endwin(); - error(1, errno, "[VX-GAMBLEGROUND] Call to randombytes_uniform failed, can't get random phrase"); - } WINDOW *banner = create_banner(col, randomnum); init_items(items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs); @@ -405,6 +402,18 @@ int spin(void *spinp) { /* 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))); + + 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) + '!'; + + // Update characters & draw them + int my, mx; + getmaxyx(p->slots->subslot[subs], my, mx); + for(int j = 0; j < 3; j++) { + mvwaddch(p->slots->subslot[subs], 2 + ((my - 2) / 6) + (((my - 2) / 3) * j), (mx - 1) / 2, p->slots->slotchar[subs][j]); + } + wnoutrefresh(p->slots->subslot[subs]); } -- cgit v1.2.3