How do I erase tiles on tilemap with a circle?

1 favourites
  • 5 posts
From the Asset Store
Each tile 64 by 64 pixels - Ultimate Tile Set for your awesome games
  • I'm trying to set "fog of war" made from tilemap (single black tile 8x8), then erase these tiles around player when he moves to reveal the visited area. I found an example by R0J0hound that uses 1px tilemap, but can't figure out how to increase the tile size to 8x8?

    dropbox.com/s/4sv6lztqwvtxbl5/destroy%20terrain.capx

  • PlayerObj exsists || FogTileMap

    Set Tile (Player.X/TileSize)+1,(Player.Y/TileSize), [emptyTile]

    Set Tile (Player.X/TileSize)+1,(Player.Y/TileSize), [emptyTile]+1

    Set Tile (Player.X/TileSize),(Player.Y/TileSize), [emptyTile]+1

    Set Tile (Player.X/TileSize)-1,(Player.Y/TileSize), [emptyTile]+1

    Set Tile (Player.X/TileSize)-1,(Player.Y/TileSize), [emptyTile]

    Set Tile (Player.X/TileSize)-1,(Player.Y/TileSize), [emptyTile]-1

    Set Tile (Player.X/TileSize),(Player.Y/TileSize), [emptyTile]-1

    Set Tile (Player.X/TileSize)+1,(Player.Y/TileSize), [emptyTile]-1

    So this checks to see if the Player Object exists. If it does then it gets the Player Position. There is an X, then Y. X is always first. If we divide the Player's X Position by the width of the tile, then we have what tile they are on. Y is for height.

    After we have those numbers we know what tile the Player is on. If we add 1 or minus 1 then we can get the tiles around the player. We can add more or minus more to affect tiles farther away. We can add nothing to them to get the tile the Player is standing on.

    Let me know if that helped

  • Hi, thanks for response, but I barely understand you. How do you imagine this: [emptyTile]+1 this will return just another tile e.g. my empty tile is 1, so 1+1=2 (2 is non-existent tile).

    UPD: Your idea will work if modified, however it makes a square but not a circle as I'm trying to implement.:

    https://i.postimg.cc/8cg6X7KL/tilemap-fow.png[/img]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It was a small error on my part. You got what I meant tho. You can add put more events with +-2, 3, or more

  • Thanks for this idea. It can be done easier:

    However it only erases just a "white square" around a player. Is there a way to make it more like a "pixelated" circle, like the one below?

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