Mouse Maze is a simple console-based game written in Go. In this game, players navigate a mouse through a maze to find cheese. The game is played in the terminal and uses basic character representations for the maze, mouse, and cheese.
⚠️ This is a fork of a previous project I did for a live coding session on YouTube. The original project can be found here.👉🏾 In this repo I will be further extending the game by adding a few more features and refactoring the code to make it more readable and maintainable. This repo will part of an ongoing stream series, which can be accessed on YouTube here.
- Your goal is to move the mouse to the cheese.
- Use WASD keys for movement:
W
: Move upA
: Move leftS
: Move downD
: Move right
- The game ends when you successfully guide the mouse to the cheese.
- Simple maze structure with a static layout.
- Console-based user interface.
- Basic keyboard input to control the mouse.
- Clear screen functionality for a smooth gaming experience.
The game uses a 2D matrix to represent the maze. The matrix is a 2D array of characters. Each character represents a cell in the maze. Navigating the matrix involves moving the mouse to a new cell by changing its X and Y coordinates.
- Go programming language
- A terminal that can execute Go programs
- Ensure that Go is installed on your system.
- Clone or download the source code from this repository.
- Navigate to the directory containing the game's source code.
- Run the game using the command:
go run main.go
Mouse
struct: Represents the player's character with X, Y coordinates.Maze
struct: Represents the game maze with a grid layout.main
: The main function sets up the game loop and handles user input.clearScreen
: Clears the terminal screen for a cleaner display.createMaze
: Initializes the maze with a predefined layout.printMaze
: Renders the maze and the mouse's position in the terminal.handleInput
: Handles player's keyboard input to control the mouse's movement.
To run the main program, execute the following in your terminal:
go run main.go
In addition to the resources provided in the first tutorial, here are some more to deepen your understanding of Go:
- GoLang-Book: A free online book that covers the basics of Go.
- Go Blog: Official Go blog with articles on best practices, new features, and community insights.
- Go Wiki: A collection of resources and community-contributed information.
- Go Modules: Understanding Go's dependency management system.
- Advanced Go Programming: Resources and articles for more experienced Go developers.
- GoLang Docs: A collection of Go tutorials and articles.