[Slick2d] Retro-Pixel Castles > Now on Steam! <

Hey man. How do render 512x512 maps of 8x8 tiles at 60 fps. When i do it with 16x16 tiles i go down to like 30-40 fps?

Are you rendering the tiles that are off screen? Even if they can’t be seen on-screen, if you still have them rendering they’re still gobbling up resources.


//Don't put this part in your loop, it's resource gobbling, put it somewhere that detects when your resolution is set, changed or on-load//
//NOTE: If you're using slick and using g.scale, you need to divide these values by your scale value. (Like g.scale(2,2) you'd have to divide the values below by 2)
int displayHeight = Display.getHeight();
int displayWidth = Display.getWidth();

//Assuming 16x16 tiles, your map coordinates are mapX/Y.
int mapTileWidth = 16;
int mapTileHeight = 16;

	for (int x = 0; x < mapWidth; x++) {
		for (int y = 0; y < mapHeight; y++) {
			if (((x*mapTileWidth)+mapX > -32) && ((x*mapTileWidth)+mapX < displayWidth+32) && ((y*mapTileHeight)+mapY > -32) && ((y*mapTileHeight)+mapY < displayHeight+32)){
				//RENDER YOUR TILES HERE//
				//X: mapX+(x*mapTileWidth)
				//Y: mapY+(y*mapTileHeight)
			}
		}
	}

I have something like that yet i get such low fps for 8x8 or 16x16 sized tiles.

I think i made it a tiny bit faster by retrieving screen width and height once.

What libraries are you using? If you’re using slick you can try putting your tilemap images in a spritesheet and drawing them all at once with drawEmbedded, like so:

(My actual, unedited code, important parts are startUse, endUse and drawEmbedded)


	public void renderBottom() throws SlickException{
		mtl.getTiles().get(0).startUse();
		for (int x = 0; x < mapWidth; x++) {
			for (int y = 0; y < mapHeight; y++) {
				if (((x*8)+mapX > -10) && ((x*8)+mapX < displayWidth+10) && ((y*8)+mapY > -10) && ((y*8)+mapY < displayHeight+10)){
					for (int l = 0; l < mapLayers; l++) {
						if (!(mapArray[x][y][l] == 0)){
							mtl.getTiles().get(mapArray[x][y][l]).drawEmbedded(mapX+(x*mapTileWidth), mapY+(y*mapTileHeight));
						}
					}
				}
			}
		}
		mtl.getTiles().get(0).endUse();

Yeah, i am using slick2d. Just trying out the draw embedded now.

Keep in mind, with drawEmbedded you can only draw one image at a time. That’s why my entire tile map is in one single spritesheet. You’ll have to plan your tile engine around that.

Alternatively, if you don’t want to use your own engine you could simple use TiledMap. It might make your life a lot easier if you don’t need much complexity in your map.
http://slick.ninjacave.com/javadoc/org/newdawn/slick/tiled/TiledMap.html

Also, there is a possibility there’s nothing even wrong with your tile map, you may be bogged down somewhere else and the tiled map is just sending you over the edge.

Yeah, i have a tileSheet/tileSet with multiple images.

Just added ‘bugged’ implementation of drawembedded and i am getting around 50+ fps.
Just need to get it drawing correctly.

Thanks

Ok, just fixed a few bugs with drawEmbedded and it works a charm. Thanks getting around 40fps now that its done.

You should still be getting more than that, unless you just have a really slow computer or you have a bunch of other stuff going on. :o

Its gone up to 60fps now for what ever reason.

Awesome! You might of had a ghost copy of the game running in the background or something, I’ve had that happen rarely with Castles. Sometimes you’ll be running 2 copies because the previous one didn’t shut down correctly. Quite annoying when you’re trying to optimize. :stuck_out_tongue_winking_eye:

“Wall” auto-transitions are now done, including a new “basic stone wall” tileset.

All terrain transitions also properly interact with each other regardless of their layer. There should be no more “illegal” layer overlapping. For example, if you try to draw rocks or forest (layer 6 and 7) over water (4 and 5), it will no longer allow it, it will either replace the water with trees/rock or do nothing depending on the situation.

http://sixtygig.com/junk/InDev-2014-06-01-3.png

That art is all very good. Do you do it yourself?

Of course! :smiley:

It’s 100% from scratch. I just start with a blank canvas and go nuts.

looks very cool and beautiful ! art, lights, can’t wait to try it !!!

and damn, how did you achieve such a fast pathfinding ? all in java ???
I had very good results after optimizing my implementation but not 5k at the same time without speed drops !
very interested in how you did…

Well, it may not be quite 5k anymore. It was 5k back on my old tile engine when the maximum map size was 256x256, now I can stably run 512x512 maps. But I should still be able to pull off numbers in the thousands, I just have not really benchmarked it yet since I’ve been focusing on the map editor. Really though my pathfinding doesn’t check the whole map, just the places flagged to be checked every cycle. So it may still run the same speed on 512x maps, short of really long one-side-to-the-other checks. But it would probably take a few hundred of those to notice anything and I don’t expect to see more than maybe 100-200 pathfinding mobs at once anyway. My coding methodology is “code for overkill not for what you will actually use”. That’s why I optimized the hell out of my tile engine until it could handle 1024x1024 maps, even though I only expect to use 512x :smiley:

I explained it the best I can in this reply a few pages back;
http://www.java-gaming.org/topics/retro-castle-survival-top-down-survival-mayhem/33101/msg/310533/view.html#msg310533

thanks a lot for your answer !
I’ll investigate with that, but for now I’ll keep my C librairies solution (no time to lose on that part for the moment) :slight_smile:

(day-night cycle is beauuutiful !)

when will you release something to try ?

Once I’m happy with it, I plan to release the map editor as the first “tech demo”. Eventually I’ll start doing weekly InDev/Alpha demo builds though, once I have more gameplay.

Starting work on the main menu. The background is a random map picked by the engine, it slowly pans around the map, hitting the edges and changing directions. There are also some Minecraftesc randomized non-nonsensical quotes right below the logo that bounce up and down, just for fun. :stuck_out_tongue:

Some plans:

  • Make the time of day on the main menu match the user’s system time. So if they launch the game at night, it’ll be dark.
  • If they’re online, make the main menu match the user’s weather. If it’s raining outside, rain in the menu! :smiley:
  • Also will load custom made maps, not just official ones.
  • All the sub pre-launch menus (Like the menu to create a new map in the map editor, or select a map in playmode) will all be part of the main menu. The windows related will just pop up in the middle of the screen when you click on something.

If you want; suggest some quotes! If they’re good I’ll toss them in. They can be anything you want, just as long as they’re somewhat PG. :wink:
(Note: 50 character limit!)

http://sixtygig.com/junk/InDev-2014-06-03-3.png

http://sixtygig.com/junk/InDev-2014-06-03-6.png

http://sixtygig.com/junk/InDev-2014-06-03-7.png

Quote: Tomatoes should be orange.
Because why not? It’s completely weird and random, so it fits perfectly into the subject. That sentence made no sense.

Anyways, try adding a rounded, transparent, bordered box around the “Retro-Pixels Castle” logo. It may make it look nicer (By separating it from the background).