flexible count of levels

This commit is contained in:
Gwenhael Le Moine 2011-07-01 16:57:19 +02:00
parent 524e4d223d
commit 10f64607e8

5
star.c
View file

@ -422,6 +422,9 @@ int main( int argc, char* argv[] )
int i = 0, lvl = 0, key; int i = 0, lvl = 0, key;
struct state *s = malloc( sizeof( struct state ) ); struct state *s = malloc( sizeof( struct state ) );
/* trick to count how many levels we have */
int nb_levels = sizeof( levels ) / sizeof( levels[ 0 ] );
/* ncurses */ /* ncurses */
WINDOW *w_main = initscr( ); WINDOW *w_main = initscr( );
cbreak(); cbreak();
@ -459,7 +462,7 @@ int main( int argc, char* argv[] )
default: default:
break; break;
} }
} while( lvl < 25 && (( key != 'q' ) && ( key != 'Q' )) ); } while( lvl < nb_levels && (( key != 'q' ) && ( key != 'Q' )) );
display_level( s ); display_level( s );
free( s ); free( s );