Building rooms with blocks...?

This forum is currently in read-only mode.
From the Asset Store
Isometric Stategy Roleplay Game Building and Streets Pack.
  • Hi... again. This question is in relation to the one I asked just before, beleive it or not... <img src="smileys/smiley17.gif" border="0" align="middle" />

    Anyway, I've got a system going where the player can build a "starship" out of square blocks, which are aligned on a grid. There are solid wall blocks, and ground blocks. I'm trying to make it so the player needs to build walls to build a room in the starship, and also need to place ground blocks in the empty space so the room is enclosed.

    What method should I use to "detect" whether the room is "complete", ex there is wall blocks enclosing the entire room and there is ground blocks taking up the whole floor (no holes). Or better yet, is there a way to detect if a whole room is created, and then fill it in with ground?

    As I said, the placing thing is all working. Just not the detection.

    Or is this too complex a thing to do?

  • Hmmm, that is a tough one. I imagine it'd possible using an array in the same way a paint bucket tool is used in a paint program, but it seems a bit inefficient since if a room isn't complete it'll have a lot of checking to do... but it might be a start:

  • Store the walls in an array and flood fill the area outside the walls, then any place that isn't filled create a floor sprite.

    I made an example capx but then noticed that this was in the CC section. I'll post it anyway since it doesn't use anything that CC doesn't have.

  • Thanks for this. This helped a lot. R0J0hound, your create fill keeps repeating and takes up processor. How can I make it so that it only creates the fill once per space rather than infinite times?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It crashes when I place multiple filled blocks.

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