Lua Maze Game Tyler Tamburlin
Project • Automatically generate random maze • Allow user to solve the maze • Utilize LOVE2D engine
Maze Generation: Backtracking • Process Select random starting cell Recursive steps Select random direction Check cell in that direction if it has been visited or is the start cell If all cells in all directions are visited return to previous cell Repeat until current cell is the start cell Select a random ending cell that occurs at end of a hall
Implementation • Lua Tables • Cell Table Information for either a wall or passage cell Whether user is in cell Cell from which the current cell was arrived at All function for variable modification • Maze Table Contains the entire maze Consists of tables containing cell tables Stores all possible directions
Maze Functions: Command Line • Functions contained in Maze table • Create Takes the width and height desired Generates a table called maze which represents a blank maze Includes a toString function in new maze table to print of command line • Backtrack Takes the maze, width and height Generates the maze using the backtracking algorithm • Usersolve Takes the maze, width and height Continually prints maze and prompts user for moves When user cell is end cell prompts user of win
Maze Functions: Love2D • Uses the same functions for create and backtrack • Utilizes two new files Main to get user size inputs Solvemaze to display maze and let user solve • Love functions Draw Draws the graphical interface for the maze Makes use of rectangle objects to draw cells, start, end and user Keypressed Allows for keyboard inputs to move user
Game: Command Line
Game: LOVE2D
Recommend
More recommend