开发者

android opengl game

开发者 https://www.devze.com 2022-12-19 00:06 出处:网络
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 t开发者_JAVA技

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 t开发者_JAVA技巧he map. But I can't figure out the best way of doing it.

Can anybody help me?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消