views:

425

answers:

2

I'm trying to develop a 2D game to android using opengl.

I know how to print images on the screen and animate them. But in my game I have a map and a want to zoom in and out and scroll the map. But I can't figure out the best way of doing it.

Can anybody help me?

A: 

The simplest approach would be to just call glTranslatef(-scrollX,-scrollY,0) followed by glScalef(zoom,zoom,zoom) before you render your map.

spurserh
+1  A: 

I don't have any api examples but I did games design at college so I'll give my two bits.

The method you use will depend on your map style, size, functionality and format.

For example if you are looking for a very static non changing map, use a simple picture image. You can use the API frame for a picture view, enabling you to zoom in and out as you do in the gallery and to scroll on zoomed images, or in this case, zoom locations on your map.

Alternatively, if your map is based off a tiling system, a good example of this is the original Pokémon and Legend of Zelda games from the old game boy, then each area stores a tile 'thumbnail' for itself as a bitmap. These are then put into their appropriate locations on a grid depending on what areas are discovered.

This is the probably the most flexible way to build your map as you are not relying on a set bitmap for the entirety your map meaning it can change its look efficiently; you can build it as desired to show areas of choice (useful for if the map only reveals places the gamer has covered) and it also means you can do tile based overlay:

ie - if a certain area should contain treasure, theres a treasure icon overlayed on that tiles x,y position on the map grid.

I used the tiling option in my game projects from college and it made everything else map related easier. It also made the map side of things smaller storage wise.

Blue