Utilizes 'Input.GetAxis("Mouse ScrollWheel")' to detect mouse scroll wheel movement.
Calls the 'Zoom' method, adjusting the camera's zoom level based on the scroll wheel input.
Additionally, implements touch-based zoom control for devices supporting multi-touch gestures.
Touch Input Handling:
Detects the first touch by checking Input.GetMouseButtonDown(0) and captures the initial touch position ('_touchstart') in world coordinates.
Supports multi-touch gestures using 'Input.touchCount == 2'.
Calculates the difference in magnitude between two touches and adjusts the zoom accordingly.
Continuous Touch Movement:
Allows the user to pan the camera when holding down the mouse button ('Input.GetMouseButton(0)').
Calculates the movement amount by subtracting the current mouse position from the initial touch position ('_touchstart').
Adjusts the camera's position based on the calculated direction, allowing for continuous movement while holding down the mouse button.
This code is responsible for helping manage maze generation. Key features of this code include:
Remove Wall Function:
The 'RemoveWall' function plays a crucial role in maze generation. Given a wall index ('wallToRemove'),
it deactivates the corresponding wall GameObject within the maze.
This function is essential for creating open paths during maze generation.
Set State Function:
The 'SetState' function dynamically adjusts the visual representation of a maze node based
on its state during a pathfinding algorithm.
Supports different states:
Available: Represents an open node, painted in white.
Current: Indicates the node the algorithm is currently processing, painted in yellow.
Completed: Marks nodes that have been visited and processed, painted in blue.
The 'GenerateMaze' function employs a randomized maze generation algorithm. It starts by initializing a set of nodes and then iteratively explores and connects these nodes until the entire maze is formed.
Iterative Exploration:
Iterates until all nodes are visited.
Checks neighbors of the current node and identifies unvisited neighbors.
Randomly selects one of the unvisited neighbors and connects it to the current node by removing the wall between them.
Updates the state/color of the chosen neighbor to indicate it's the new current node.
Backtracking:
If the current node has no unvisited neighbors, backtracks by marking the current node as completed.
Sets the state/color of the completed node to blue, indicating it has been processed and will not be revisited.
Removes the completed node from the current path.
Visual Representation:
The algorithm dynamically adjusts the color and state of nodes in the maze to provide a visual representation of the maze generation process. Current nodes are shown in yellow, completed nodes in blue, and available nodes in white.
The Assignment
This project was a solo project I decided to make in my free time. I got the idea from reddit when browsing the algorithm and computer subreddits. For the generation I used Depth First Search to make the maze. I Implemented this in Unity 2022 and I think this is quite a nice portfolio piece hence why I have made a page for this.
For perfomance reasons I decided to limit the maze to 100 x 100 so that the program would not lag enormously when viewed on less powerfull devices. I implemented the GUI and the Camera Behaviour so that this application could be run on mobile devices as well.