So I'm adding the basic mechanic of making frail/breaking tiles, those that break apart and disappear after the player has walked ontop of them. Now I thought this would be as easy as...:
//Breaking tiles represents the 2d array number, that describes the breaking tiletype.
if( TileWeAreStandingOn == breakingTile){
//frameCount is a variable that counts the frames, after 30 frames (1 second) the tile disappears.
frameCount++;
if(frameCount > 30){
//So, when 30 frames has passed, the tile is removed
TileWeAreStandingOn = noTile;
frameCount = 0;
}
}
Now this works, but it only works WHILE you are standing on the breaking tile, once you jump, the countdown stops since the initial if-statement is not valid anymore. So I am trying to find ways around this where the player could jump onto a frail/breakable tile, and then jump onwards, and the tile would still break after 1 second. Also, if he walks past several breakable tiles in a row, they should all break timely, that is, they should all break after a second of the player has moved off of that tile. (which would result in a domino like timing, where one breaks shortly after another)
I need to make the tiles work independently, so that each tile reacts and starts to disappear/break whenever the player touches it. But my system is build around how the player interacts with the 2d array map and the tiles aren't independent entities, only the player is.
So I'm asking for suggestions how I can make the tiles react independently based on Players interactions with them? Especially in this case, where a tile should disappear a second after the players has touched it.
Thanks in advance guys!