The_dude8080

Handle huge maps

Recommended Posts

Hello. I was wondering how you handle huge maps in a game. I am more like a phaser user but I guess the idea behind it must be the same too all other cases. I know phaser bitmap has a limit size (it seems like it) so I can't just load millions of tiles into a bitmap for example. I can't load them "one by one" in the game because that would make the fps horrible... so what? Should I create lots of bitmaps and load them according to player position in the map? Like some kind of "map pooling"?

Share this post


Link to post
Share on other sites

I don't really understand what you are asking, but for my game, my mapping system is a giant 2x2 array that acts as a map. Each entry in the array is a 32x32 pixel block on the map, the entries are all numbers 0-11 which correspond to what kind of tile to place there. When a player walks around I just get info from the array to see what to load next. This was easier for me than what you suggest. 

Share this post


Link to post
Share on other sites

Hmm then if map is something like this:

var map = [0,0,0,0,
           1,1,1,1,
           1,1,1,1,
           0,0,0,0]

// Would you do something similar to this?

function GenerateMap (player_position) {

     for(var x = 0; x < map.length; x++) {

       if(player.position.x > 300 && player.position.y > 300) { // just random values
           if(map[x] == 1) // add the sprite equivalent to type "1";
           if(map[x] == 2) // add the sprite equivalent to type "2";
       }

     }

}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.