mirror of
https://github.com/gwenhael-le-moine/c-urs_-toil-s.git
synced 2024-12-27 09:58:44 +01:00
introduce some naughtiness, use ncurses' KEY_ codes to define direction
This commit is contained in:
parent
73717a08a0
commit
9585ed44d3
1 changed files with 6 additions and 12 deletions
18
star.c
18
star.c
|
@ -279,11 +279,11 @@ typedef enum { /* characters used to design levels */
|
|||
GIFT = 'x'
|
||||
} cell;
|
||||
|
||||
typedef enum { /* values aren't strictly necessary but useful for unit-testing */
|
||||
UP = 'u',
|
||||
DOWN = 'd',
|
||||
LEFT = 'l',
|
||||
RIGHT = 'r'
|
||||
typedef enum { /* and now a nasty trick to slightly simplify key handling */
|
||||
UP = KEY_UP, /* we'll use ncurses codes to define directions */
|
||||
DOWN = KEY_DOWN,
|
||||
LEFT = KEY_LEFT,
|
||||
RIGHT = KEY_RIGHT
|
||||
} direction;
|
||||
|
||||
struct options { /* store how the game is started (controlled by --arguments) */
|
||||
|
@ -601,16 +601,10 @@ int main( int argc, char* argv[] )
|
|||
key = getch();
|
||||
switch( key ) {
|
||||
case KEY_UP:
|
||||
make_a_move( s, UP );
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
make_a_move( s, DOWN );
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
make_a_move( s, LEFT );
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
make_a_move( s, RIGHT );
|
||||
make_a_move( s, key );
|
||||
break;
|
||||
case ' ':
|
||||
switch_actor( s );
|
||||
|
|
Loading…
Reference in a new issue