Starting my Maze Game: Grid

There are so many ideas in my head and it’s about time I start trying to get them all out. One of the ideas that I have thought of just recently would be this Maze Game. It is a very simple idea that involves a maze! That was the very basic idea that soon evolved into something that could possibly become a game that people might want to play.

This idea for a Maze Game came about after I was shown my list of Learning Outcomes for this Trimester. I stared inserting other ideas into this Maze Game to help complete a couple of these Outcomes. Just a couple of small things that I can include to make this game both something other than a Maze Game and, at the same time, knock out a couple LO’s while I’m at it. So this game is definitely still, at it’s core, a game about a maze but I will be adding things here and there as my ideas develop a little more.

Being primarily a maze game, I need to create a maze. But having one maze would be boring and having to create multiple myself would take too much time and unneeded effort. Not wanting to waste my time, I have decided to create a random maze generator. The random maze generator will have to be resized and have a varying difficulty level depending on different variables such as “Map Size” or “Map Difficulty”. “Map Size” will not change with “Map Difficulty” and vise versa.

With resizability in mind, I have created a Grid generator that the maze will use to generate on top of.


The grid algorithm takes 2 variables that are the max X and Z variables that the grid will generate. For example, if you are to input a max X of 4 and a max Z of 10 then you would end up with a grid that is 4 spaces across and 10 spaces back (Example above). This is accomplished with some very basic C# code and a prefab.

public Transform gridSquare;
 public int maxXValue;
 public int maxZValue;
 private int currentZValue = 1;
// Use this for initialization
 void Start () {
 for (int i = 0; i; maxZValue;)
 Instantiate(gridSquare, new Vector3(currentZValue * 1.1f, 0, i * 1.1f), Quaternion.identity);
 if ((i == (maxZValue)) & (currentZValue != maxXValue))
 i = 0;

This code has a loop that places tiles along the Z axis until it reaches it’s maxZValue. Once it reaches it’s given maxZValue it then moves 1 along the X axis and starts the loop again until it reaches it’s maxXValue.

Placing this script onto an empty game object in my scene and then giving my prefab into the public variable “gridSquare” (my prefab just being some representation of a grid square), I successfully created a Grid Generator.

This is just the first step of creating my Maze Generator and I am sure that my code is only going to get more complex from here.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s