Maze project

profilen_thanmek
helpers.pdf

// This function very simply updates which direction my runner is facing. I am tracking this via a // variable named 'facing' that I've declared in the global scope like this: // direction facing; // So, turn_right() just needs to check the current value of 'facing' and then update it to the next // direction based on its current value. static void turn_right(void);

// While you could implement turn_left() very similarly to turn_right(), it's probably easier to just // call turn_right() three times inside of turn_left() since three right turns == one left turn. static void turn_left(void);

// This function calls maze_get_char() and returns its result passing in the current x and y values plus // or minus an offset of one based on the current value of 'facing'. In this way it returns the // character in front of the runner. static char get_facing_char(void);

// Move forward updates the runner's x or y position by one based on the current value of 'facing' static void move_forward(void);

// This function just checks to see if the runner is standing on the 'E' static bool is_at_destination(void);

// This function calls maze_get_char() passing in the current x and y position of the runner to get the // charadcter under the runner's feet. Then, based on the value of that character (that is, whether that // character is a ' ', a '.', an 'o', an 'O', or an '@') it calls maze_set_char() to update the character // to the next type of breadcrumb. static void update_breadcrumb(void);