Using fast integer hashing algorithm the HashUtil came alive in the project. Plants are now placed based on exact hash values of a Cube's coordinates. That way things look like random, yet results are always exact, making the terrain usable for exact gaming and data-less Save and Load...cool and fast. Look, there we have two continental trees with 2% chance to appear (yet they will appear there each run!), and some palms with 5% chance to appear. :-)
The code is rather simple now:
public BaseFloraGenerator()
{
addFlora(Continental.CONTINENTAL_ID,ClimateLevel.CLIMATELEVEL_ID,new FloraListElement[]{new FloraListElement(new Grass(),true),new FloraListElement(new OakTree(),2), new FloraListElement(new CherryTree(),2)});
addFlora(Tropical.TROPICAL_ID,ClimateLevel.CLIMATELEVEL_ID,new FloraListElement[]{new FloraListElement(new Sand(),true),new FloraListElement(new CoconutTree(),5)});
}
Sunday, 24 June 2007
Hash, hash, silence
Labels:
concept,
hardcoding
Subscribe to:
Post Comments (Atom)
2 comments:
Fascinating :-)
And it's only the beginning! :-D
Post a Comment