Problems randomly generating tiles in sequence

0 favourites
  • 9 posts
From the Asset Store
Piano tiles
$9.99 USD
Template for a piano tiles game, fully documented in comments and video
  • Heya guys,

    I'm having some problems randomly generating sprites.

    The goal of the event system is to populate the layout with randomly generated square sprites which represent rooms with doors on either side.

    The array "RoomFormation" represents the population of possible room combinations. Green sides represent doors where the object is named after the orientation of the doors (t=top, r=right, b=bottom, l=left).

    The size of "RoomFormation" is 16x5 where there are 16 different sprite objects (x-axis), the name of the sprite object (y-axis=0), and the possible relative locations where the sprite can be placed (x.1, x.2, x.3, x.4 where the 1 refers to placement in the north, 2 is east, 3 is south, and 4 is west; i.e a "1.3 means a 't' tile placed in the south.)

    Theory:

    The function "TileRoll" goes through a process of scanning the "Grid" array for previously placed tiles and eliminates (zeroes the value) incompatible tile objects from "TilePool" (a copy of "RoomFormation"), then it draws a random value from "TileLottery" (a contracted "TilePool" array containing no zero values), from the randomly chosen value a tile is placed in the appropriate location.

    [

    [The "TileRoll" function is made in such a way to prevent 3-way intersections from occuring randomly]]

    Problem:

    Randomly, the process halts before MaxRoom tiles are placed.

    In the time being I've added the highlighted condition in Event2-3 to restart if the process fails, however this is not something I want to keep in.

    Screenshot examples of successful and failure layout generation:

    http://imgur.com/a/5Wyv3

    Cap file itself:

    https://www.dropbox.com/s/u1zjtvg31mbp2 ... .capx?dl=0

  • How exactly do you determine which sides have doors?

  • How exactly do you determine which sides have doors?

    The sprites for each room have green sides to represent a door or doors and are named appropriately.

    For example:

    That sprite is named 'tr' to show that it has a door on the top and right.

  • So how to you check the nearby tiles to see if their doors match up?

    Something like:

    Array.At(x+1,y) > contains('t') or contains('r') ... etc. ?

  • So how to you check the nearby tiles to see if their doors match up?

    Something like:

    Array.At(x+1,y) > contains('t') or contains('r') ... etc. ?

    When checking the arrays for which door they contain I chose not to use strings or characters to label the types of rooms.

    Instead the room configurations have an identity by number (1-15). I'll include the diagram (it's not sorted, but it's labeled)

    I felt that numbers and characters would probably have worked the same; thinking that using comparisons between integers would be faster than comparing characters.

  • Bump.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry, I have been insanely busy lately.

    But you need a better schema for identifying which tile has which doors.

    Sadly, I have not developed such a system yet, only theorized about what I might do in such a system, so I will be of limited help.

    I would recommend studying cesisco 's work here:

    You might have to ask if he will share his capx with you (Or publicly).

  • Maybe this could help, it's a different way to look at the problem without using arrays. It first creates the rooms with door in between so everything is connected. Then as a second pass it has a chance to add a few more random doors to make looping passages.

    https://www.dropbox.com/s/45t57qr04dzht ... .capx?dl=1

    It's similar to what i've done previously here:

    roguelike-map-system-untiled_p590128?#p590128

  • Sorry, I have been insanely busy lately.

    But you need a better schema for identifying which tile has which doors.

    Sadly, I have not developed such a system yet, only theorized about what I might do in such a system, so I will be of limited help.

    I would recommend studying cesisco 's work here: viewtopic.php?f=159&t=189186

    You might have to ask if he will share his capx with you (Or publicly).

    Not a problem man. Thanks for looking into this.

    Maybe this could help, it's a different way to look at the problem without using arrays. It first creates the rooms with door in between so everything is connected. Then as a second pass it has a chance to add a few more random doors to make looping passages.

    https://www.dropbox.com/s/45t57qr04dzht ... .capx?dl=1

    It's similar to what i've done previously here:

    roguelike-map-system-untiled_p590128?#p590128

    That simplifies things quite a bit, which is awesome. I was originally thinking that working with arrays would be best as it would be easy to reference what the current values are, which would be useful for mini-maps and such. Thanks a ton!

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