|
Allegro.cc
Projects
Resource Directory
|
IOTD: tile based maze
tile based maze, by Johan Halmén
I haven't re-invented the wheel for a long time, so inspired by a recent thread I decided to make a maze algo. Here's the result. The black parts are the paths in the maze. The maze world is simply a w*h array where each cell is either a square wall brick or empty. No thin walls. The Maze class has a member char **maze, which holds the maze data. 0 for a hole, 2 for a brick. (1 is used for marking during creation.) I have about 200 lines of code that I might upload somewhere on a.cc, if someone is interested in it
Doesn't seem to be enought variation. A little too easy to follow. - DanielH
Hey, at least it looks good; I think it's cool that your algo managed to produce a somewhat open "chamber" type room (right there, upper-middle)... But, do you mind labeling the start/finish? heehee - Gideon Weems
I said: The black parts are the paths in the maze
I didn't mean it looked bad, just that you he should try to adjust algorithms to get rid of those little one step deadends. - DanielH
I know, I should just forbid one step deadends. And the maze is easy to follow. I made the program colour the start and the farmost node. Knowing it was the farmost it was easy to find by eye. But as soon as I made a moving point, controlled with the keyboard, it got more difficult. Your eyes and thought are faster than your fingers and you see bigger structures and patterns without the moving point. - Johan Halmén
Now you need to develop a first-person-view engine to explore that maze with! Sort of inspires me to make my own, actually... - Michael A. Johnson
Well done... can you reverse the colors so white is the pathway though? It hurts my eyes and feels unatural. This would be a good start for a game similar to diablo where the dungeon randomizes for every level... wolfenstein style! - Adol
The algo goes like this (extremely simplified): [pseudo_code] Step(int x, int y, int direction) { if (tile ahead, tile to the left and tile to the right == wall) make this tile path else return if (rand() % 100 < 75) Step( on tile ahead, direction); if (rand() % 100 < 95) Step( on tile to the left, direction-1); if (rand() % 100 < 95) Step( on tile to the right, direction+1); } The rand() lines make it interesting. With the probabilities you get longer or shorter straight lines of path. I guess I'll make it into some kind of maze explorer with a gui that lets you change those parameters. And the colours, too. - Johan Halmén
Look at [url=http://www.vollebregt00.freeler.nl/t/tankzone.html]TankZone[/url], a game I made really long ago. In random.c is the maze generation code. Turn it on in the configuration file. (random_map=1 I think)
-- Tobi - Tobi Vollebregt This section is only available to registered Allegro.cc members.
:: Join Allegro.cc The Gallery | Add your own image! |
Poll
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||