refactor orientation
This commit is contained in:
parent
750136ab17
commit
105fdcfd82
36
w/w.c
36
w/w.c
|
@ -34,8 +34,8 @@
|
||||||
|
|
||||||
#define NORTH 0
|
#define NORTH 0
|
||||||
#define EAST 1
|
#define EAST 1
|
||||||
#define WEST 2
|
#define SOUTH 2
|
||||||
#define SOUTH 3
|
#define WEST 3
|
||||||
|
|
||||||
#define TILE_WALL 0
|
#define TILE_WALL 0
|
||||||
#define TILE_FREE 1
|
#define TILE_FREE 1
|
||||||
|
@ -408,40 +408,12 @@ void forward()
|
||||||
|
|
||||||
void right()
|
void right()
|
||||||
{
|
{
|
||||||
switch (state.position.orientation)
|
state.position.orientation = (state.position.orientation + 1) % 4;
|
||||||
{
|
|
||||||
case NORTH:
|
|
||||||
state.position.orientation = EAST;
|
|
||||||
break;
|
|
||||||
case SOUTH:
|
|
||||||
state.position.orientation = WEST;
|
|
||||||
break;
|
|
||||||
case EAST:
|
|
||||||
state.position.orientation = SOUTH;
|
|
||||||
break;
|
|
||||||
case WEST:
|
|
||||||
state.position.orientation = NORTH;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void left()
|
void left()
|
||||||
{
|
{
|
||||||
switch (state.position.orientation)
|
state.position.orientation = (state.position.orientation + 3) % 4;
|
||||||
{
|
|
||||||
case NORTH:
|
|
||||||
state.position.orientation = WEST;
|
|
||||||
break;
|
|
||||||
case SOUTH:
|
|
||||||
state.position.orientation = EAST;
|
|
||||||
break;
|
|
||||||
case EAST:
|
|
||||||
state.position.orientation = NORTH;
|
|
||||||
break;
|
|
||||||
case WEST:
|
|
||||||
state.position.orientation = SOUTH;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dumpstate()
|
void dumpstate()
|
||||||
|
|
Loading…
Reference in New Issue