Jump to content

Handle huge maps


The_dude8080
 Share

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"?

Link to comment
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. 

Link to comment
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";
       }

     }

}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...