Jump to content

Large Levels cause my game to lag massively


bearkin333
 Share

Recommended Posts

I'm working on a project where I need to create a large map randomly. I've been looking up randomly generating rooms and algorithms for that business, but that's not really what's causing my problem.
I generate a level-map, which is basically a grid of numbers that tells each spot in the grid what kind of tile it will be. After the level is fully generated, it goes through my level-map and generates tiles as sprites with physics bodies for the player to walk on. It's important that they be separate because each tile can be destroyed.
Unfortunately, I'm finding that while this is fine in a 20x20 room, once I make levels like this any larger my game starts undergoing quite a bit of duress. At around 100x100, the game is incredibly slow. I don't think I'd ever need to make a room that large, but even then, I'm sure there's a better way to do all this, I just don't know what it is.

Any ideas? Thanks in advance!

Link to comment
Share on other sites

Updating this thread because I've found a fix that works very well. By adding the tiles into a group, and doing group collisions against only the moving entities, rather than everything, I cut out each of the ten-thousand or so tiles colliding with each other. I'll leave this here for anyone else experiencing something similar.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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