Java Render Only Intersecting? -
so wondering how run through multi-dimensional array without having use loops test whether or not objects intersecting in rectangle , render interesting?
currently i'm using 2 loops go through , within nested loop have use intersecting()
method , since needs happen every frame game getting low fps. assume it's because have 650x350 entities in array. i'll show code below , restate question. official question how test whether or not entity intersecting rectangle camera doesn't lag game?
for (int x = 0; x < entities.length; x++) // entities.length 650 { (int y = 0; y < entities[0].length; y++) // entities[0].length 350 { if (camera.intersecting(entities[x][y])) { entities[x][y].render(g); // x , y indices multiplied 32 position } } }
this depends quite bit on mechanics of game. in general sense recommend looking quadtrees ( http://en.m.wikipedia.org/wiki/quadtree). check nodes camera overlaps , draw contents.
Comments
Post a Comment