6 ms·
Gravity: An orbital simulation game written in Elm
- rnhmjoj 12y agoSome 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.
- xixixao 12y agoCool, for some reason unplayable in FF, fine Chrome.
- codygman 12y agoYeah, 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.
- 6581 12y agoSimilar: http://voar.io/ http://voar.io/
- StevePerkins 12y agoI 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/
- xkarga00 12y agoAnother similar game in Elm https://github.com/johnpmayer/celestia https://github.com/johnpmayer/celestia http://johnpmayer.github.io/celestia/ http://johnpmayer.github.io/celestia/
- cwyers 12y agoThe 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 12y agoSimilar to some of the worlds in the hit game Osmos: http://www.osmos-game.com/ http://www.osmos-game.com/
- teleclimber 12y agoI came here to say that. The orbital levels in Osmos are excellent.
- ChuckMcM 12y agoI 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.
- teraflop 12y agoI 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 12y agoBecause of the nature of FRP, you can't do much except for Euler integration.
- abecedarius 12y agoHow 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.)
- vertex-four 12y agoWhy not, precisely?
- shanemhansen 12y agoI too wasted lots of time playing with these simulations. The feyman lecture on physics have a great chapter on this stuff. The orbit does tend to pick up energy due to errors coming from euler's method. A relatively simple way to make your orbits a bit more stable is to normalize your velocity vectors using conservation of energy.
- fenollp 12y agoI'd say the newly gained acceleration is due to [1] the force of attraction suddenly disappearing. [1] https://github.com/stephenbalaban/Gravity/blob/master/Gravity.elm#L93 https://github.com/stephenbalaban/Gravity/blob/master/Gravit...
- jarcane 12y agoI'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.
- z3t4 12y agoWhen 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.
- grey-area 12y agoDo the simulations include the asteroid belts? Wouldn't those have a stabilising effect on the rest of the bodies in the system?
- skj 12y agoMuch 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.