Hi everyone!
I'm trying to make a simple automation factorio-like game, however i'm facing some issues.
In order to generate the map I've started with the "Procedural Terrain Generation" from the example browser, and that's very nice, the chunk system works nicely when seen from above too, so chunks of terrains are saved in a JSON and loaded when needed, perfect.
So I need to destroy and recreate sprites while the player moves around in order to save up on memory, which i did, it works, awesome BUT I need the factories, furnaces, etc... to keep working even when destroyed!
So I thought, well I will put every structures in an array that will control everything from backstage (factory production, conveyor belts, etc...) and will be refreshed every tick or so.
But that means that even with a map of 100*100, and with an array depth of 50 in order to register data from every square, that would already be 500.000 array cells to be read every ticks, no way that wouldn't overload the CPU.
Plus the size of that array is currently limited, I don't know how to resize it and make it go larger in every way in order to register the player's expansion in the world.
So two questions really:
- How would you deal with managing factories and belts in the background?
- How can I resize the array dynamically, is it even the right way to go about it?
Thank you so much for any help or idea :)