GameDev.net Posting Guidelines (please read before posting)
For Beginners Forum FAQs (please read before posting)
Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 22 April 2012 - 07:21 AM
Posted 22 April 2012 - 09:31 AM
Posted 22 April 2012 - 09:57 AM
How would it work for a game where I wanted planets to continue to function no matter where the player is?
double moneyOnPlanet(float time) { return startingMoney + sin(time); }Whenever you're in range of a planet and need to know how much money it has, evaluate the function with current time. Function above is simple and will return fluctuating value.
List<Planet> getPlanetsAtSystemAt(int x, int y, int z) { Random r = new Random(x * y * z); int nPlanets = r.nextInt() % 10; List<Planet> p = new List<Planet>(nPlanets); for (int i = 0; i < nPlanets) { p.add(new Planet(r.nextInt()); // parameter is starting money } return p; }Now, as you move around space, and need to know if there are any planets at (x,y,z), just evaluate the above. It will give same result no matter when it's called, meaning that result doesn't need to be stored.
Posted 22 April 2012 - 03:59 PM
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.