diff --git a/w/w.c b/w/w.c index 2e72c69..04e7970 100644 --- a/w/w.c +++ b/w/w.c @@ -34,8 +34,8 @@ #define NORTH 0 #define EAST 1 -#define WEST 2 -#define SOUTH 3 +#define SOUTH 2 +#define WEST 3 #define TILE_WALL 0 #define TILE_FREE 1 @@ -408,40 +408,12 @@ void forward() void right() { - switch (state.position.orientation) - { - 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; - } + state.position.orientation = (state.position.orientation + 1) % 4; } void left() { - switch (state.position.orientation) - { - 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; - } + state.position.orientation = (state.position.orientation + 3) % 4; } void dumpstate()