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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -