I've tried to get animated tiles to work on my tile map and I've run into what may be a problem going forward.
I'll try to explain how I have it constructed in my code.
My map class stores two vectors, one with tiles (one of each kind) and one vector stores "tile slots".
It also holds a tile sheet.
My tile class handles updating the sprite animation, only changes coordinates for the target sprite.
Handles frame rate etc.
It also holds an ID to connect this with a tile slot ID.
My tile slot class holds ID, type, and x/y for where to draw them on the map.
ID is used to link it to a tile during rendering.
I did it like this because it was the only way I could think of, this way I could make it so that I only need to update the animation once per tile.
However, when I need to draw the tile slots for where the animated tile will be drawn I run into the problem of having to go through all tile slots and then go through all tiles to draw the correct tile at the correct place.
I can cut down on some of it by checking if the tile slot is inside of the camera, but this still leads to going through the entire tile slot vector.
My worry is that this will be very taxing on the computer when I get to the point of making a full fledged map. Not to mention when I will have to in some way check for collisions with the tile slots.
I wish that someone could maybe give some input on this.
Edited by Nausea, 24 June 2013 - 06:30 PM.