Hi. So this is something I've been thinking about for a while, and that is, how do you create an actual functioning relative game world?
Well, I sat down today and made it, and was surprised when it didn't take very long at all.
What it does and why
It basically finds a "center" of the universe. It means that the actual origin which in most games is at (0, 0) is not constant, but determined by the location of every other object, the average. In this way no-one can really say they are at the center of the universe, because the center is not literal, it's just where everything else seems to be.
And as for the reason, this demonstrates that there can in fact, logically, be a center of the universe. Trouble is we would need to first explore the entire universe and find the density of everything just to find it.
This is such a simple idea I'd be surprised if no-one had tried it before.
It's basically 3 steps.
1. For each object, add the object's coordinates to a global variable.
2. Divide this global variable by the amount of objects to find the average position.
3. Take away this average from the current positions of every object, and add a constant offset value to keep it centered rather than in the top left corner at (0,0).
And that is all there is to it.
Interesting, but what would be the practical application?
Pretty much not a whole lot, though it could be useful in making a game set in space that had a lot of moving objects over a long period of time, in order for the actual objects to not move too far away from the origin point or more accurately to move the origin point to wherever. The actual xorigin and yorigin coordinates could be useful in calculation for spawns and such, e.g. distance away from the center (which would have the highest density of objects) determines the chance to spawn something, such as a black hole.
It works with scroll too I believe, but I'll have to try that one out. Right now it's practically useless though, since there's no real need for it in anything I'm thinking of working on.
This is mainly just a proof of concept for some metaphysics. Well if ever I create a space RPG it'll be useful though! =P
That's how boids usually start.
Btw if you set it to unbound scrolling then 0,0 really would be the center of an infinite universe, if you don't mind a few rounding errors of course.
I can take the smell of a gameplay mechanic of something really unique and cool but just can't pinpoint it...
Develop games in your browser. Powerful, performant & highly capable.
Well, a massive scale - no, infinite - universe destroyer god game might be interesting!
Hmm. Not a bad idea actually, might be my next project.
I suppose it would be pretty easy to make this into a boid. All you would have to do is apply some varying forces instead of setting position.