Random tiling with a path?

0 favourites
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Yann, thanks for the fix.

    And yeah, that was a pretty face-palm error, haha.

    About the cell size error, so many globals and different numbers everywhere (I'm trying to keep track of all this in my head), sometimes I forget to update something!

    I did the formula for placing startsprite and endsprite very late at night, but now I see what you mean.

    And yeah, I figured I was creating an infinite loop when I saw nothing but gray on my screen ;)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Why don't you just make a snake? Start at a random vertical position at the left, and "snake" randomly to the right, then store the coordinates into a 2D array. When done you simply randomize the parts of the array NOT updated, then voila! ;)

  • JoyfulDreamer

    That was my first idea actually, but you have to constantly check that your next random step would still allow you to reach the goal. So you basically have to pathfind for each step.

    Unless you decide to just allo the snake to bit its tail.

    But than how much iteration until you'll really reach the goal?...

    I found that using a maze algo, it creates interesting looking random path and that you always end up with something valid.

  • Well, the number if iterations wouldn't be more than the number of blocks you need to write to, so not much different. ;) Maze algos might be better, but not necessarily faster. You have to backup usually (retrace steps) to find a new open slot and continue (or at least store the most recent one found and return to it). He didn't want a "maze" in his original post, and as per his request, so that's why I suggested it. ;)

    Excal - it really depends on the type of path you want, and if the ending path must land in a specific position.

  • JoyfulDreamer

    Yeah that's a valid way, I don't deny it. But the "asynchronousity" of the pathfinder makes it a bit of a pain to implement.

    (I think even the map generation is asynchronous and there's no trigger for that... might have to request that)

    And as far as speed goes, he only does that on start of layout it seems. So.. it should be ok as long as he doesn't have more than maybe 2000 grid cell (since I used recursivity, you might stack overflow)

  • Doesn't have to be asynchronous if you loop while true. ;)

  • hmmmmmmmm

    You mean, catching a trigger event in an infinite while loop?...

    hmmmmmmmm....

    Nah won't work if you work inside another trigger (function/on start of layout)

    So I don't see what you mean by that then (: example?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)