My sandbox game

Hi,

Been working on this game for around two weeks on and off when I have time, doing the procedural landscape generation which is using
a mix of perlin noise and cellular automata.

My blog website with latest screen shot is at:

https://sites.google.com/site/sterrialand/development/news/cavesarelookinggood

Wanting to add trees to the top level now, got an idea of how, but would like your thoughts on how you would work out
placing trees on the grass layer?

Think I may have put this post in the wrong section as thinking it was just a forum for 2d java games!

I’m using Libgdx and OGL.

Thanks,
Steve

Yeah, I think this is meant to go in WIP games, tools & toys.

yeah, you should move this to W.I.P

Hi Steve,
Your Game already looks very well.

For your trees try this:
First you should try to create one tree with tasks like finding the height where to place the tree or also to create a tree with a random height/size, etc…
After that you can try to program an algorithm that goes from the left to the right and “plants” some trees.
Therefore you should calculate the distance between each tree like:


	public void plantTree(Tree lastTree) { 
		if(lastTree != null) {
			Tree nextTree = new Tree();
			int randomDistance = 10; // here some random values for the distance would look nice as well
			nextTree.setX(lastTree.getX() + lastTree.getWidth() + randomDistance);
			nextTree.grow(); // this method should create a single tree
			
			if(nextTree.getX() + nextTree.getWidth() < gameWidth) {
				plantTree(nextTree); // recursion
			}
		} else {
			//case of the first tree		
		}
	}

I hope this will help you,
PlainBug