how do i do this thing that will allow me to do other things

0 favourites
  • 8 posts
  • I'm looking to create a random dungeon generator, but being new I've hit a snag relatively early. So far I generate a room, and want to pick a single and random wall that is touching said room. However, all of the walls that are touching the room generate a door instead of only one, and do so in an (understandably) ordered way.

    Also, using the "at start of layout" condition causes no doors to generate at all.

    Is that enough information?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Event sheets are read top to bottom, so if you use on start of layout then you need to make sure that your room is created before you look for overlaps to create a door. All events will be checked each tick (depends on your monitor rate, but usually 60 times per second) so if you don't have a trigger once or other limiting condition for something like this then your walls will be checked a lot... Also, because of the way that events work, you don't need the for-each loop as that selects each wall in turn and will create a door for each one that meets the or group criteria.

    So... remove the for each loop and move the overlap check (events at line 2) and put them after the create room events (line 7 / 8) under the on start of layout.

  • Event sheets are read top to bottom, so if you use on start of layout then you need to make sure that your room is created before you look for overlaps to create a door. All events will be checked each tick (depends on your monitor rate, but usually 60 times per second) so if you don't have a trigger once or other limiting condition for something like this then your walls will be checked a lot... Also, because of the way that events work, you don't need the for-each loop as that selects each wall in turn and will create a door for each one that meets the or group criteria.

    Yeah, that's what I figured.

    So... remove the for each loop and move the overlap check (events at line 2) and put them after the create room events (line 7 / 8) under the on start of layout.

    That doesn't work. Instead, not a single room is generated. I'm thinking it attempts to generate it, but unless I get very lucky and RNG lands on the 20 or so applicable squares out of 1,000 possible I wont be seeing it.

  • Are you able to upload a capx? It's almost impossible to guess what might be causing it not to work otherwise.

  • here

    thanks for the assistance btw, it is appreciated.

  • Here you go! I've done some housekeeping with the events, to change the emphasis of the overlap check filters and to add a wait 1 tick event so that the first set of walls are destroyed before checking where to put the door.

    link

  • Great, thanks for the help. Though, can you tell me the significance of using an offset of five for the proximity checks? Seems arbitrary, but it works.

    EDIT: oh, and i just noticed that doors occasionally spawn in the corners of the room which is illogical considering the player cannot reach it.

  • Offset 5 just moves the room enough without creating the possibility of an overlap happening on wall objects that are not adjacent to the room; ie moves less than the wall object width.

    I'll only be able to try this later, but for doors to appear inside the room then sometimes wall objects are not being destroyed first. Which is probably caused by asking too much of the engine in one tick/event when creating a lot of wall objects and then destroying some of them at the same time.

    Try changing the events by moving the room overlap check and wall destroy events to be under a tickcount =1 condition. Then move the door create check events to be under a new tickcount =2 condition.

    I think that'll work but I won't be able to check until later to be sure.

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