Archived
1
0
Disbranĉigi 0

Replace numbers with constants

This commit is contained in:
Jaidyn Ann 2020-05-31 02:49:08 -05:00
parent 889194c9ca
commit f117b2c5c8
4 changed files with 24 additions and 11 deletions

View File

@ -149,8 +149,8 @@ calc_menu ( struct eMenu* menu, int sp_select_button )
else if ( spGetInput()->button[SP_BUTTON_UP] ) else if ( spGetInput()->button[SP_BUTTON_UP] )
menu_select_up( menu ); menu_select_up( menu );
else else
return -1; return CALCMENU_NOINPUT;
return 0; return CALCMENU_MOVED;
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------

View File

@ -1,5 +1,8 @@
#include <sparrow3d.h> #include <sparrow3d.h>
#define CALCMENU_NOINPUT -1
#define CALCMENU_MOVED 0
struct eMenu; struct eMenu;
struct eMenuElement; struct eMenuElement;

View File

@ -46,11 +46,13 @@ draw_test ( void )
testMenu->surface ); testMenu->surface );
spFontDrawMiddle( spGetWindowSurface()->w/2, spFontDrawMiddle( spGetWindowSurface()->w/2,
spGetWindowSurface()->h-fonts[0]->maxheight*2.5, 0, spGetWindowSurface()->h
"Press [S] to select", fonts[0] ); - fonts[FN_COZETTE]->maxheight * 2.5, 0,
"Press [S] to select", fonts[FN_COZETTE] );
spFontDrawMiddle( spGetWindowSurface()->w/2, spFontDrawMiddle( spGetWindowSurface()->w/2,
spGetWindowSurface()->h-fonts[0]->maxheight-2, 0, spGetWindowSurface()->h
"Press [E] to exit", fonts[0] ); - fonts[FN_COZETTE]->maxheight -2, 0,
"Press [E] to exit", fonts[FN_COZETTE] );
spFlip(); spFlip();
} }
@ -59,13 +61,15 @@ int
calc_test ( Uint32 steps ) calc_test ( Uint32 steps )
{ {
int menucode = calc_menu ( testMenu, SP_BUTTON_START ); int menucode = calc_menu ( testMenu, SP_BUTTON_START );
if ( menucode == -1 ) // no input? interpret keypress as our own
if ( menucode == CALCMENU_NOINPUT )
if ( spGetInput()->button[SP_BUTTON_SELECT] ) if ( spGetInput()->button[SP_BUTTON_SELECT] )
return -1; return -1;
else else
return 0; return 0;
if ( menucode > 0 ) // greater than _moved means it returned the inc'd menu selection index
if ( menucode > CALCMENU_MOVED )
spSleep(700000); spSleep(700000);
// sleep long enough after selection to play selection sound lol // sleep long enough after selection to play selection sound lol
return menucode; return menucode;
@ -96,12 +100,13 @@ init ( void )
void void
init_test_menu ( struct eMenu* menu ) init_test_menu ( struct eMenu* menu )
{ {
init_menu( menu, "what do you do? <3", &fonts[1], &fonts[0], init_menu( menu, "what do you do? <3",
&fonts[FN_LOVEMECHAIN], &fonts[FN_COZETTE],
spGetRGB(80,80,80), spGetRGB(35,71,107) ); spGetRGB(80,80,80), spGetRGB(35,71,107) );
menu->titleCentered = 0; menu->titleCentered = 0;
menu->textCentered = 0; menu->textCentered = 0;
menu->moveSound = sounds[0]; menu->moveSound = sounds[SF_TAMBORINE];
menu->selectSound = sounds[1]; menu->selectSound = sounds[SF_EEUH];
add_menu_element(menu, "give up"); add_menu_element(menu, "give up");
add_menu_element(menu, "run away"); add_menu_element(menu, "run away");
add_menu_element(menu, "eat a baby"); add_menu_element(menu, "eat a baby");

View File

@ -1,5 +1,10 @@
#include <sparrow3d.h> #include <sparrow3d.h>
#define FN_COZETTE 0
#define FN_LOVEMECHAIN 1
#define SF_TAMBORINE 0
#define SF_EEUH 1
int calc_test ( Uint32 ); int calc_test ( Uint32 );
void draw_test ( void ); void draw_test ( void );
void resize ( Uint16, Uint16 ); void resize ( Uint16, Uint16 );