I would imagine storing the entire world as an integer array and only adding the on-screen objects from the array would certainly do it. This was a rather rushed project however, but if you have a different solution, I am certainly interested to hear it, Spilli :)
Cocky is interested too if you care to translate your solution to German (lol)
Well for a start I would not store the whole world in memory. On start up make it build the world and save it in region based files. I'd then make it load only the region's within X distance. If an active region is no longer within view distance, it's destroyed and removed from active memory.
If you don't understand me, just say and I'll make a quick prototype.
Ah. See I tried storing the entire world in one gigantic randomly-generated text file but this caused problems for java to read the entire document. I've been kinda off Greenfoot for awhile though, I might hop back on just to try your suggestion out.
Too bad Greenfoot doesn't allow security permissions to read/write to text documents; that will make my job a tiny bit harder...
Thanks for your input Spilli :)
Don't use a text document, and don't bulk it up. I'd make is so each region (chunk of the world) use it's own file. This mean's you only have to load what you require. Plus I wouldn't use a text document, I'd recommend saving in a raw format which will save tons of space.
To identify regions you could give them identification numbers which would vary upon their location within the 2D space for example:
int regionId = (y / Region.SIZE) + ((x / Region.SIZE) << 8);
I'd also recommend keeping the region size to the power of two. Best of luck. :)
2012/8/13
2012/8/13
2012/8/20
2012/8/20
2012/8/20
2012/8/20
2012/8/20
2012/8/21
2012/8/21