mirror of
https://github.com/gwenhael-le-moine/c-urs_-toil-s.git
synced 2024-12-27 09:58:44 +01:00
add typedef'd enums, use direction's
This commit is contained in:
parent
0aea5112e4
commit
11f804d1cf
1 changed files with 8 additions and 11 deletions
19
star.c
19
star.c
|
@ -6,11 +6,8 @@
|
||||||
#define LEVEL_HEIGHT 9
|
#define LEVEL_HEIGHT 9
|
||||||
#define LEVEL_WIDTH 16
|
#define LEVEL_WIDTH 16
|
||||||
|
|
||||||
#define WALL '#'
|
typedef enum { WALL='#', BALL='@', CUBE='H', VOID=' ', GIFT='*' } cell;
|
||||||
#define BALL '@'
|
typedef enum { UP='u', DOWN='d', LEFT='l', RIGHT='r' } direction;
|
||||||
#define CUBE 'H'
|
|
||||||
#define VOID ' '
|
|
||||||
#define GIFT '*'
|
|
||||||
|
|
||||||
char* levels[] = { "################"
|
char* levels[] = { "################"
|
||||||
"#@## *#H#"
|
"#@## *#H#"
|
||||||
|
@ -316,7 +313,7 @@ int won_or_not( struct state *s )
|
||||||
return( count_gifts( s ) == 0 );
|
return( count_gifts( s ) == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void move( struct state *s, int direction )
|
void move( struct state *s, direction where )
|
||||||
{
|
{
|
||||||
int dx = 0, dy = 0, tmpx, tmpy, *item_coord;
|
int dx = 0, dy = 0, tmpx, tmpy, *item_coord;
|
||||||
item_coord = malloc( sizeof( int ) * 2 );
|
item_coord = malloc( sizeof( int ) * 2 );
|
||||||
|
@ -324,17 +321,17 @@ void move( struct state *s, int direction )
|
||||||
tmpx = item_coord[ 0 ];
|
tmpx = item_coord[ 0 ];
|
||||||
tmpy = item_coord[ 1 ];
|
tmpy = item_coord[ 1 ];
|
||||||
|
|
||||||
switch( direction ) {
|
switch( where ) {
|
||||||
case 'u':
|
case UP:
|
||||||
dy--;
|
dy--;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case DOWN:
|
||||||
dy++;
|
dy++;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case LEFT:
|
||||||
dx--;
|
dx--;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case RIGHT:
|
||||||
dx++;
|
dx++;
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
|
|
Loading…
Reference in a new issue