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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.