mirror of
https://github.com/gwenhael-le-moine/c-urs_-toil-s.git
synced 2024-12-26 09:58:48 +01:00
add next/prev level and reload functionalities
This commit is contained in:
parent
37f02c757d
commit
6a36c45a6e
1 changed files with 19 additions and 1 deletions
20
star.c
20
star.c
|
@ -419,7 +419,7 @@ void display_level( struct state *s )
|
|||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
int i = 0, lvl = 0, key;
|
||||
int i = 0, lvl = 0, key, load_requested = 0;
|
||||
struct state *s = malloc( sizeof( struct state ) );
|
||||
|
||||
/* trick to count how many levels we have */
|
||||
|
@ -439,6 +439,9 @@ int main( int argc, char* argv[] )
|
|||
do {
|
||||
if ( won_or_not( s ) ) {
|
||||
lvl++;
|
||||
}
|
||||
if ( load_requested == 1 ) {
|
||||
load_requested = 0;
|
||||
load_level( s, levels[ lvl ] );
|
||||
}
|
||||
|
||||
|
@ -460,6 +463,21 @@ int main( int argc, char* argv[] )
|
|||
case ' ':
|
||||
switch_actor( s );
|
||||
break;
|
||||
case 'n':
|
||||
if ( lvl < nb_levels - 1 ) {
|
||||
lvl++;
|
||||
load_requested = 1;
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
if ( lvl > 0 ) {
|
||||
lvl--;
|
||||
load_requested = 1;
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
load_requested = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue