Fast way of rendering Tiles.

Hello there again JGO,

Currently I am working on an infinite map-generator, or atleast trying to. But evrytime I want to test/try something it will take a BIG, I mean a very BIG part of the CPU :/. I am without my code running on 60 ticks, 200 frames, but with the infinite Tile-rendering codes it is going to be 60ticks, 39frames (And this is with almost no tiles, around 200, while I was running the old code 50*50 tiles = 2500tiles…) My rendering code is just a simple arrayList with some if’s and looping throught all the tiles :confused: not the greates… while my other code was just searching for that tile and not looping over the arrayList like 1000times more then is needed…

    	for (LevelTile t : tiles) {
	     	if(t.y >=  (yOffset >> 3) && t.y  <= (yOffset + screen.height >> 3) + 1){
	     		if(t.x >= (xOffset >> 3) && t.x <=  (xOffset + screen.width >> 3) + 1){
	     			t.render(screen, this);
	        	}
	        }
    	}

Is there a way for searching x’s and y’s better then this? Like:

    	for (int y = (yOffset >> 3); y < (yOffset + screen.height >> 3) + 1; y++) {
        	for (int x = (xOffset >> 3); x < (xOffset + screen.width >> 3) + 1; y++) {
        		//Searching in the ArrayList tiles to x and y and then just .render(); it
        	}
    	}

Is the example possible? Or another solution? Just say it!
-RoseSlayer, and yes I didn’t found anthing on java.docs