You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
866 B

  1. #include "labyrinth.h"
  2. #include "global.h"
  3. #include "stdio.h"
  4. #include "stdlib.h"
  5. void turn_direction_right(Direction *direction){
  6. switch (*direction) {
  7. case N:
  8. *direction = E;
  9. break;
  10. case E:
  11. *direction = S;
  12. break;
  13. case S:
  14. *direction = W;
  15. break;
  16. case W:
  17. *direction = N;
  18. break;
  19. }
  20. }
  21. void lab_move(unsigned short *x, unsigned short *y, Direction direction){
  22. if (direction == N){
  23. *x = *x - 1;
  24. return;
  25. }
  26. if (direction == E){
  27. *y = *y + 1;
  28. return;
  29. }
  30. if (direction == S){
  31. *x = *x + 1;
  32. return;
  33. }
  34. if (direction == W){
  35. *y = *y - 1;
  36. return;
  37. }
  38. }
  39. void set_wall(State** field, unsigned short x, unsigned short y) {
  40. field[0][0] = WALL;
  41. }