gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Animated map tiles

#1382 - Papa Smurf Advanced - Fri Jan 17, 2003 1:51 pm

Guys,

How do You get animated tiles in your maps ?

any suggestions ?

#1383 - col - Fri Jan 17, 2003 2:03 pm

I'd like to expand that question :)

Does anyone have an elegant way to implement animated background tiles into a dynamic bg tile allocator.

Most importantly with consideration for easy map generation and editing.

The approach I have come up with would probably require the development of a custom editor and i'd like to steer clear of that.

I would rather be able to use one of the available free pcx/bmp to map and tileset apps - or an editor that can import existing tile/map data.

cheers

col.

#1386 - Splam - Fri Jan 17, 2003 2:22 pm

Hmmm I've got my own tools to handle this and it does use an editor for saying "here's the bit that will change" then it just reserves enough tiles at the start of the set for that area, then you're sure of always having enough to do a straight dma copy of the whole area if you want.

I suppose you could draw your bitmap and use one of the available tools but when you're drawing it you need to replace the animating areas with some tiles that aren't going to be repeated (maybe a pattern in the tiles) and therefore removed by the software. Then draw your animated areas for that in other bitmaps, convert those and the 1st one will have the tiles reserved for you to blit into.

eg 0 = picture 1-c = animating area

000000000000000000000000
000001234000000000000000
000005678000000000000000
000009abc000000000000000
000000000000000000000000

then you know those tiles 1-c are the ones that are going to change. Not sure how the free map/tile editors work but you'd need to find out which tiles are the ones (1-c in this case) that are being used for the defined area. Would be fantastic if you could shuffle the order of the tiles to get them all in order (map editor will probably grab them in rows of the screen so you'll have tiles between each lines worth of animating area).

then you draw your animated bitmaps

1234
5678
9abc

1234
5678
9abc

etc each of which is a different frame. Grab those and you've got the data to replace in the main map.

Obviously this is worst case stuff (ie, vram is FULL and you've got to do dynamic updating), if you just want to animate a couple of tiles somewhere then dump new data to them every frame or if there's enough room in vram to have all the frames then you only need to alter your map instead.

#1468 - Arek the Absolute - Sun Jan 19, 2003 4:53 am

Well, let me start by saying I haven't implemented animated tiles at all in my own project, but I have thought about how I will do it when I get there. When I first programmed any tile based games, it was on DirectX, and whenever I reached the loop where I drew to the screen, I simply said if (tile == 6 && conditionforanimation == true){tile = 16;} or something like that. It could be done similarly on the GBA, that is to say, whenever the tiles need to go to the next frame, look through the map data and change all the necessary numbers. The problem with that, though, is that then you need to spare tiles for animation, meaning you have less available on the map. Secondly, it's just plain slow. Solution? Why change the map data? Say, every second, or however often you need, you simply DMA copy the image data for the next frame into the appropriate place in the tile data. Just keep it using the same map data, but change what the animated tiles look like.

Sorry for taking so long to get to my point. :)
-Arek the Absolute
_________________
-Arek the Absolute