go to next level when current one is won, number of level hardcoded

This commit is contained in:
Gwenhael Le Moine 2011-07-01 16:50:37 +02:00
parent c8b4e33795
commit 524e4d223d

23
star.c
View file

@ -413,14 +413,13 @@ void display_level( struct state *s )
default: break; /* ignore newlines */ default: break; /* ignore newlines */
} }
} }
/* printf( "\n" ); */
} }
refresh(); refresh();
} }
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
int i = 0; int i = 0, lvl = 0, key;
struct state *s = malloc( sizeof( struct state ) ); struct state *s = malloc( sizeof( struct state ) );
/* ncurses */ /* ncurses */
@ -431,13 +430,15 @@ int main( int argc, char* argv[] )
intrflush( w_main, FALSE ); intrflush( w_main, FALSE );
keypad( w_main, TRUE ); keypad( w_main, TRUE );
load_level( s, levels[ 0 ] ); /* load the first level to start the loop in a correct state */
load_level( s, levels[ lvl ] );
display_level( s );
/* char* moves = "drdluruldrdlrulurudlurdul"; */
int key;
do { do {
if ( won_or_not( s ) ) {
lvl++;
load_level( s, levels[ lvl ] );
}
display_level( s ); display_level( s );
key = getch(); key = getch();
switch( key ) { switch( key ) {
@ -453,12 +454,12 @@ int main( int argc, char* argv[] )
case KEY_RIGHT: case KEY_RIGHT:
make_a_move( s, RIGHT ); make_a_move( s, RIGHT );
break; break;
case ' ':
switch_actor( s );
default: default:
break; break;
} }
/* make_a_move( s, key /\* moves[ i ] *\/ ); */ } while( lvl < 25 && (( key != 'q' ) && ( key != 'Q' )) );
/* i++; */
} while( ( ! won_or_not( s ) ) && (( key != 'q' ) && ( key != 'Q' )) /* && ( moves[ i ] != '\0' ) */ );
display_level( s ); display_level( s );
free( s ); free( s );