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.

Beginners > Tile Map Position to ScreenBaseBlock Position Formula

#34842 - Celeryface - Thu Jan 27, 2005 1:27 am

Does anyone know of a formula to convert a tile position from a 256x32 (in tiles) map into a 64x32 (in tiles) ScreenBaseBlock?

For reference, I need to use the formula after collision detection to replace the tile in the map with another tile (ie taking a coin off the screen after collecting it).

Thanks again for the help. :)

#34843 - DekuTree64 - Thu Jan 27, 2005 1:46 am

MS Paint is the secret :)
Or a piece of paper. Try drawing out your screen map and BG map and label a few tiles to get a good idea what's what, and figure up a formula from there.
Sorry I'm too lazy to work it out myself, but hopefully it will be pretty obvious once you get a good look at the situation.

Notepad is also one of my good friends for working out complicated ideas, though probably not too helpful for this particular problem.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#34845 - Celeryface - Thu Jan 27, 2005 2:03 am

DekuTree64 wrote:
MS Paint is the secret :)
Or a piece of paper. Try drawing out your screen map and BG map and label a few tiles to get a good idea what's what, and figure up a formula from there.
Sorry I'm too lazy to work it out myself, but hopefully it will be pretty obvious once you get a good look at the situation.

Notepad is also one of my good friends for working out complicated ideas, though probably not too helpful for this particular problem.


Is this a formula that is commonly used?

#34846 - DekuTree64 - Thu Jan 27, 2005 2:24 am

Celeryface wrote:
Is this a formula that is commonly used?


I don't think so. Most games I've seen use sprites for coins and things that get picked up, so there's no need to modify the BG data.

Sometimes you do need to change things in the BG though, like to make a door open or blow something up.
Even then you don't need a specific formula though, if you go the route most games do and set up a BG scrolling system to use a single 32x32 screen and copy in strips of tiles at the edges. Then you only need to change the map data that the scrolling system references and ask it to redraw the screen.

Scrolling systems are tricky though, so I wouldn't really recommend trying to write one right away. I would recommend using sprites for anything that changes though, that will make things much easier.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#34848 - Celeryface - Thu Jan 27, 2005 2:50 am

DekuTree64 wrote:
Celeryface wrote:
Is this a formula that is commonly used?


I don't think so. Most games I've seen use sprites for coins and things that get picked up, so there's no need to modify the BG data.

Sometimes you do need to change things in the BG though, like to make a door open or blow something up.
Even then you don't need a specific formula though, if you go the route most games do and set up a BG scrolling system to use a single 32x32 screen and copy in strips of tiles at the edges. Then you only need to change the map data that the scrolling system references and ask it to redraw the screen.

Scrolling systems are tricky though, so I wouldn't really recommend trying to write one right away. I would recommend using sprites for anything that changes though, that will make things much easier.



Yeah, I copy to the edges of the screen rather than drawing the entire 32x32 section of the map each frame.

I'm sure there's a little formula, just gotta figure it out. :P

Edit: I guess I could ask to redraw the map area during a collision, as you suggested as well.

#34849 - Celeryface - Thu Jan 27, 2005 2:58 am

Your idea about redrawing after a collision worked :)

Thanks for the idea.