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)
}
}
}
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();
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.
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.
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.
“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.
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
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)
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.
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!
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.
(Note: 50 character limit!)
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).