I'm currently working on a sandbox game that could be compared to games like Terraria or Starbound in that there's a 2D world filled with blocks that the player can manipulate.
The world consists of chunks (similar to how it works in Minecraft) which are loaded by a number of threads when the camera approaches them.
This is what the game currently looks like:
Each colored square represents a chunk. I zoomed out a little in order to make the borders where the chunks are being loaded visible. The camera / view starts at the top left corner of the world and going right or down makes the game load and render more chunks.
Now, I have two problems with with the game:
The first one is the memory usage. When I load the chunks the memory usage increases. When I return to the main menu of the game, the memory usage doesn't return to its original value, though, despite removing the tables which store the chunks. This issue seems to be more present on Windows than Linux, however it seems like the game suffers from it on both platforms. Please note that the memory that's increasing is not in use by lua (I've checked with collectgarbage("count")), but rather by the Löve framework itself (I guess?).
The second problem is that the more chunks I load, the slower the game runs. Again, the slowdown still persists even after returning to the main menu. This problem is, however, only persistent on Windows. I tested the game on Xubuntu and the fps go back to their original value (around 300 fps) after returning to the main menu, while still staying low on Windows. Please note that the slowdown that's happening when loading more chunks before going to the main menu is understandable, as the game is rendering more and more chunks and it's doing so without any sprite batches whatsoever (Don't worry, I'll fix that later.).
If you wish to download the love and test the game out for yourself, here are the controls:
- SPACE - to launch / start the game when it's in the launcher / main menu
- WASD - move the camera / view around (please move right and / or down, as the camera starts in the top left corner of the world)
- 1 AND 2 - zoom out / in (warning: be careful when zooming out; there's a bug that makes the view flip when you zoom out too much)
- ESC - return to main menu
- ThePC007