Deliverables
Add a New Maze
Your task is to add a new maze to the program. Currently, you have one maze contained inside of an array. Instead, you’ll need to update the data variable to be a multidimensional array. Here’s an example of another maze you can use:
Adding a new maze is going to affect every aspect of your program. Here’s all the things that will need to be updated or added in your project:
- Player location: This keep tracks of the player’s location at the start of the maze. You’ll now need to keep track of it for many mazes. You can use an array for this.
- Current maze: You have an integer variable that tracks the current maze.
- Carrot locations: This is another array that should keep track of all the various carrot locations.
- State variables: Along with the arrays, you should define the following @State variables: playerRow, playerCol, wonGame, carrotRow, and carrotCol.
- Changing the maze: The best way to update the maze is when the user taps the button. Here’s an example:
.alert("Congrats! You won!", isPresented: $wonGame) {
Button("OK") {
// update maze code
}
}
This is a challenging task so take it one step at a time. The key thing is to attempt the challenge. Give it some time and if you are stuck, then review the answer key. Good luck!