

Gravity: An orbital simulation game written in Elm - of
https://github.com/stephenbalaban/Gravity

======
ChuckMcM
I have a soft spot for gravity simulators, my first BASIC program that wasn't
a variation on INPUT "Your Age";A :PRINT "You are ", A*52, " weeks old." was a
gravity simulator with a rocket in orbit and your capsule needed to dock with
it by apply forward or reverse thrust (2D only!) What made mine a bit
different was that you launched from the planet so you had to take into
account where the other rocket was before launching or you wouldn't have
enough fuel to dock.

What this example in Elm and all reasonably implemented simulators provoke is
a sense of awe in just how hard it is to "drive" in orbit.

------
StevePerkins
I wasn't familiar with Elm prior to seeing this submission. To save others a
few minutes of web searching, it appears at first glance to be a marriage of
Haskell and Dart... a functional programming language that transpiles into
JavaScript. It's primary use cases seem to include browser-based games, and
reactive widgets.

[http://elm-lang.org/](http://elm-lang.org/)

~~~
dons
Nothing to do with Dart. It's a Haskell + FRP signals, that compiles to JS.

~~~
tome
He means it's like Dart in the sense that it compiles to JS.

------
teraflop
I always enjoy playing with these kinds of simulations, but this one seems to
be pretty bad at respecting conservation of energy. The closer you are to the
sun, the more rapidly your spacecraft mysteriously gains energy from nowhere,
causing it to spiral outward instead of maintaining a stable orbit. I'm not
sure yet whether it's a consequence of using naive Euler integration or some
other bug.

~~~
notthemessiah
Because of the nature of FRP, you can't do much except for Euler integration.

~~~
abecedarius
How about
[http://en.wikipedia.org/wiki/Symplectic_Euler_method](http://en.wikipedia.org/wiki/Symplectic_Euler_method)
?

That's what I used in
[http://wry.me/t/gravity/gravity.html](http://wry.me/t/gravity/gravity.html)
(Which is not in Elm; it simulates a solar sail instead of a rocket.)

------
rnhmjoj
Some time ago I played a bit with elm and made this: [http://share-
elm.com/sprout/5467ef7de4b00800031feadf](http://share-
elm.com/sprout/5467ef7de4b00800031feadf), not a simulation of course but the
effect it's nice. It's cool to see an actual simulation, now. Well done.

------
cwyers
The way the lines of force are illustrated (even the colors used) is very
reminiscent of New Orbit, which is still one of the most innovative games I
have seen for Android.

[http://blackish-games.com/neworbit/](http://blackish-games.com/neworbit/)

------
andrewljohnson
Similar to some of the worlds in the hit game Osmos: [http://www.osmos-
game.com/](http://www.osmos-game.com/)

~~~
teleclimber
I came here to say that. The orbital levels in Osmos are excellent.

------
xixixao
Cool, for some reason unplayable in FF, fine Chrome.

~~~
codygman
Yeah, I was really big into elm until I started noticing how slow many of my
programs were on Firefox. Everything runs great in Chrome however.

------
jarcane
I've been keeping an eye on Elm for a while; it's a very intriguing idea, but
I've yet to see much other than little demos like this done with it. This
seems to be the chronic case of gaming in the FP and Lisp worlds. Lots of
little demos and experiments, very few mature projects.

------
xkarga00
Another similar game in Elm
[https://github.com/johnpmayer/celestia](https://github.com/johnpmayer/celestia)
[http://johnpmayer.github.io/celestia/](http://johnpmayer.github.io/celestia/)

------
6581
Similar: [http://voar.io/](http://voar.io/)

------
z3t4
When making gravity simulations you need to "cheat" a little to make the
planets and the stars keep a stable orbit. It makes one amaze over how stable
our own star system is.

~~~
skj
Much of that is due to issues of numerical approximation, which isn't an issue
for our actual planets.

Though, unlike newtonian planets, our planets can precess slightly due to
general relativity thingies.

