How do I add solid borders around a randomly sized area?

0 favourites
  • 6 posts
From the Asset Store
Customize the animation of character when item changed
  • Hi,

    I recently found this random map generator on YouTube: youtube.com/watch and have been tweaking it to generate randomly sized rooms.

    I'm now stuck on how to make the surrounding areas (the yellow area in the screenshot) solid so that the character sprite doesn't pass through them.

    When the rooms were a set size I added a solid tiled background sprite around the edges, but don't know if it's possible to reuse this technique when the X and Y values are randomised.

  • Not sure if I follow you, didn't he spawn the Dark Grey Tiles which have the solid behaviour? why not keep using the same logic and close the walls of the room for the edges?

    Even if you do a Tiled background the rooms on your picture still show that is open so it will be a bit confusing for the player if it shows that can pass but when you try is blocked like an invisible wall.

    You have multiple ways to do this but I still dont see where your issue is, if you have a Tiled BG solid the same size as one of those tiles and then you extend it either (Verticaly for left & right) or (Orizontal for Top & Bottom) then you check the last tile of each side then place you solid wall one tile after.

    For me, it sounds like the side walls have to be fully closed using the same dark great tiles that you spawn through the level.

    Unless Im missing something.

  • I haven't looked at the source yet but if the problem is that you don't know where to position your border because the position can be random/variable, then the solution is usually to save the randomized value in a variable so that it can be used for other things later.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks oosyrag and tarek2.

    tarek2 I thought about closing the walls using the existing tiles but can't work out how to extend them by checking the last tile on each side, as you described. Could you give an example please?

  • Thanks oosyrag and tarek2.

    tarek2 I thought about closing the walls using the existing tiles but can't work out how to extend them by checking the last tile on each side, as you described. Could you give an example please?

    To be honest I think this system will work better with TileMaps as you will have as benefits:

    -A much easier way to create the sectors using the "TileMap Brush"

    -Fewer objects to spawn if you want to create bigger dungeons.

    -Easier to move around the sectors.

    -Just one object to track (Sector & Tiles) are all in one.

    etc...

    So I recreated it with TileMaps:

    https://www.dropbox.com/s/c2divb1fminlvrh/Dungeon%20Generator.c3p?dl=0

    Another benefits is that You can always switch to spawn normal Sprites as tiles if you need to, so it covers both.

  • Hi tarek2,

    Thank you so much for this, it's been extremely helpful. :)

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