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'
|
GIFT = 'x'
|
||||||
} cell;
|
} cell;
|
||||||
|
|
||||||
typedef enum { /* values aren't strictly necessary but useful for unit-testing */
|
typedef enum { /* and now a nasty trick to slightly simplify key handling */
|
||||||
UP = 'u',
|
UP = KEY_UP, /* we'll use ncurses codes to define directions */
|
||||||
DOWN = 'd',
|
DOWN = KEY_DOWN,
|
||||||
LEFT = 'l',
|
LEFT = KEY_LEFT,
|
||||||
RIGHT = 'r'
|
RIGHT = KEY_RIGHT
|
||||||
} direction;
|
} direction;
|
||||||
|
|
||||||
struct options { /* store how the game is started (controlled by --arguments) */
|
struct options { /* store how the game is started (controlled by --arguments) */
|
||||||
|
@ -601,16 +601,10 @@ int main( int argc, char* argv[] )
|
||||||
key = getch();
|
key = getch();
|
||||||
switch( key ) {
|
switch( key ) {
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
make_a_move( s, UP );
|
|
||||||
break;
|
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
make_a_move( s, DOWN );
|
|
||||||
break;
|
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
make_a_move( s, LEFT );
|
|
||||||
break;
|
|
||||||
case KEY_RIGHT:
|
case KEY_RIGHT:
|
||||||
make_a_move( s, RIGHT );
|
make_a_move( s, key );
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
switch_actor( s );
|
switch_actor( s );
|
||||||
|
|
Loading…
Reference in a new issue