How do I erase certain tiles.

0 favourites
  • 7 posts
From the Asset Store
Each tile 64 by 64 pixels - Ultimate Tile Set for your awesome games
  • So I'm making a terraria-like game, but I don't know how to phrase an event that would delete the tile my player is standing on when i press space. Someone please help.

    P.S. The player is 10, 10 size and the tiles are 16, 16 size

  • In the manual there is an action for erase tile:

    https://www.scirra.com/manual/172/tilemap

    So the only other thing you need is a reference of where your character is on the tilemap, which I assume the second expression on that page will work -> PositionToTile

    Then you would have to add 1 to the Y tile so it destroys the tile underneath the character's feet.

  • In the manual there is an action for erase tile:

    https://www.scirra.com/manual/172/tilemap

    So the only other thing you need is a reference of where your character is on the tilemap, which I assume the second expression on that page will work -> PositionToTile

    Then you would have to add 1 to the Y tile so it destroys the tile underneath the character's feet.

    ya but can u give an example. I dont know how to phrase

  • I'm not near Construct right now but I would wager

    On Space

    -Erase Tile: PositionToTileX(CharacterSprite.x), PositionToTileY(CharacterSprite.y)-1

    Or, if tile size 16 then PositionToTileY(CharacterSprite.y-16)

    I can take a look in Construct later and be more exact but that's the idea.

    Also, I would actually wrap it in a function so you can reuse it later

    On Space -> Call.Function("eraseTile", PositionToTileX(CharacterSprite.x), PositionToTileY(CharacterSprite.y-16))

    Function "eraseTile"

    -Erase Tile

    --X = function.param(0)

    --Y = function.param(1)

    But if you aren't familiar with functions start the testing without it

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • its not working. Can you upload a capx? Or should I to see if something is wrong

  • Sorry it took a little while, I was at work before.

    ...and I took a little time to make the capx fun (for me at least):

    https://www.dropbox.com/s/z4erazryf5tb0 ... .capx?dl=0

    I organized and commented everything to try and make it easy to follow but feel free to ask me any questions!

    Enjoy!

    *Note: The images were obviously taken from Mario 2. I hope that doesn't get me in trouble anywhere as this was only for learning purposes.

  • ...after playing around a little with the grenades this actually makes me want to make a game with a totally destroy-able environment. Imagine instead of Toad a guy with a bazooka completely wrecking a city . . .

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