

-----------------------------------

bigdaddygamer2

Fri May 28, 2010 8:38 am


Turing Maze Help

-----------------------------------

Help with turing maze, it is controlled by the mouse and i need help with the collison detection, when it recongizes when it has hit the wall. I made the maze in a seperate program and then loaded it in turing.


-----------------------------------

TerranceN

Fri May 28, 2010 9:24 am


RE:Turing Maze Help

-----------------------------------

This is a good time to use whatdotcolour. Assuming your maze is all one colour, you can use whatdotcolour to find the colour at a location like this:

whatdotcolour(x, y)

then you can just check if that colour is the colour of the maze.

Hope that helps.


-----------------------------------

DtY

Fri May 28, 2010 7:26 pm


RE:Turing Maze Help

-----------------------------------

I'm doing something similar in python right now, whatdotcolour() will do what you want, and will be rather easy, but if you're interested (or anyone else), here's the more mathematical way.

This assumes that every cell in the maze is the same size, and all walls intersect perpendicularly.

First of all, you need a way to represent the maze as a data structure. A simple way to do it is to create a two dimensional array that will hold each cell. Each cell will need two variables (I think in Turing you would create a struct), bottom and right (top and left would work similarly), both booleans. These represent whether or not that wall is there.

When the player moves, you want to check the x and the y separately.

First, check if it crosses a space in the x direction, if it does, check if there is a wall between these two spaces. If the player moves right, you want to check the right wall of the cell that the player is leaving, if they are moving left, you want to check the right wall of the cell they are entering. If there is a wall there, the player can't move there, and the program should act accordingly (most simply, by not moving them).

Do the same in the y direction.

This method isn't perfect though, the main problem I'm having with it is that the player accelerates as they move, and if there is a long enough corridor before a wall they can sometimes jump over it, because they've accelerated enough to go from one cell to another skipping one in the middle, the program will only check  one wall, and let the player go right over the other.

---

By the way, procedural maze generation is surprisingly easy, you might want to consider it, it will make your game a lot more interesting if there is a new maze every time the program starts. Check it out: https://secure.wikimedia.org/wikipedia/en/wiki/Maze_generation

I'm using the depth first search algorithm, and it's only about twenty lines of python.

