Maze Generation code in Monkey


Click image to see it full size

I decided to add a random maze to a game I’m working on called Cyber Citadel (coming soon).

I’m using the cross-platform Monkey language and thought I’d post the code in case other people found it useful. The code uses a stack and a recursive backtracking algorithm.

8 Responses to “Maze Generation code in Monkey”

  1. Taiphoz Says:

    Hay Jake, About your code, given your using WordPress , there are a number of plugins that you can use which will syntax highlight your code and make it look way cooler and easier to read..

    You can see it in action here [ http://www.littleember.com/2011/03/27/testing-a-code-snip/ ]

    The Plugin is called Crayon Syntax Highlighter and comes with Monkey Support. :)

  2. Grey Alien Games Says:

    Woah sounds cool thanks. Guess I should use it for future code posts and update this one.

  3. Jochen Says:

    https://gist.github.com is your friend ;) (Yes, it supports Monkey Language – no need for plugin)

  4. Grey Alien Games Says:

    Great! Used gist. For some reason when I used Monkey formatting it all went red at the class declaration. So I opted for text only but at least it kept the indents.

  5. Xerrabaldy Says:

    Blast, that’s why I was questioning you on twitter when you posted that image. I was hoping it was written with Blitzmax as I’m planning to convert a very old Vic20 maze game and thought you might have saved me some time :)

  6. Grey Alien Games Says:

    Well this should be fairly easy to convert to BlitzMax! Give it a go.

  7. Xerrabaldy Says:

    I disagree because I’m neither familiar with Monkey’s syntax and not altogether completely comfortable with methods and types in Bmax.

    Looking through this you seem to have this Class statement which appears to be some kind of new Function but i could be off track.

    It looks like you use a method outside of a function at the start – which completely threw me.

    You’re using at the end of some variables – is this instead of [] and you’re just passing variables that way? What on earth does Local a:T[][] = New T[rows][] actually mean?

    Probably someone who’s used to both languages would make sense of it but I think maybe I should stick to the simpler stuff for now :)

  8. Jake Birkett Says:

    Class is Type in BlitzMax

    The method should be part of the Level Class. I just separated as I had loads of other code in my level class that isn’t needed for this example.

    “You’re using at the end of some variables ” What does that mean?

    Local a:t[][] is a 2D array of a generic type. You can just make a 2D array of TRoom in BlitzMax, it’ll work fine.