How do I calculate the surface area of a player designed room?

0 favourites
  • 4 posts
From the Asset Store
Player's Follower
$7 USD
30% off
Players follower. use it for anything which follows the player
  • Howzit?

    I'm making a game where you drag walls at 90 and 45 degree angles to design rooms much like in The Sims or any architecture game, but I'm having a lot of trouble making the game recognize rooms.

    My first idea was to have the player tell the game, "This is the bedroom, this is the bathroom, and this is the kitchen," with player placed zones. I want the room to have a green overlay when it's given a zone so that the player can clearly see and deactivate zone view.

    To make a room fill with a zone upon being clicked, (paint bucket style) I went with a tilemap. I made areas fill with a new "room zone" tile when clicked, but after much research I don't believe it's possible to then have the game recognize how many there are of a tile on a tilemap. I also tried building the floor out of sprites which, when clicked, will activate adjacent floor sprites as "IsRoom = True" until they meet a wall, but I can't figure out a way to make each tile only spawn a single transparent "room zone" sprite on top of it. That's because each sprite is being touched by many other active "IsRoom" tiles for even a single tick.

    I appreciate any alternative ideas or solutions!

  • en.wikipedia.org/wiki/Flood_fill

    You don't have to recognize how many of a given tile are on a tilemap. Just increment a counter variable for each tile filled during every iteration of your filling loop to keep track of it yourself.

  • That's a great idea! After messing around more with the tilemap though, how would you determine how many tiles changed in the last tick or action? My mind goes to something like:

    (Beneath the actual flood fill)

    On Left Button Clicked: Set Global Variable NewTiles to Tilemap.TilesChanged

    But obviously Tilemap.TilesChanged isn't a real expression.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • During the filing process, you will have a loop that repeats each step, or tile changed. In addition to changing the tile, add one to a variable at the same time. Your variable will keep track of the number of tiles changed.

    You're basically making your own "tiles changed" counter.

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