This is a very simple n body simulation I’m working on in love2d so i can learn the framework and try and understand some of the equations I’ve learned at school. It supports euler and verlet integration..
Used ChatGPT to format the README
This is a very simple n body simulation I’m working on in love2d so i can learn the framework and try and understand some of the equations I’ve learned at school. It supports euler and verlet integration..
Used ChatGPT to format the README
It’s finally done! I would have loved to add a few extra features, like a proper 3D perspective camera and the ability to download planetary data from the NASA Horizons API, but with exams coming up, I won’t have the time to squeeze them in before Flavortown end.
All in all, I built a simple N-Body simulator that supports Euler and Verlet integration, with a Solar System preset. The most challenging part was implementing the 3D camera. Love2D is designed for 2D games, so getting all the math right to make a 2D framework display a (kind of) convincing 3D simulation took a lot of work.
I’m especially proud of the UI. Thanks to the nuklear-love library, it was easy to implement but made the project look much cleaner and more polished.
This was a lot of fun! I still plan to continue working on this project after my exams and the Flavortown event ends. There’s still plenty of room for improvements, and it’s far from perfect.
The simulation now has a main menu and a proper information panel, implemented using the love-nuklear library. In addition, you can now press “r” to toggle the rendering of the planets’ names.
Log in to leave a comment
2 month have passed! And i kind of forgot about this project…
For this update, i wasted a lot of time trying to write a plot class, which i scrapped in the end. The only (substantial) addition i have to show is 3D rendering (without perspective). There’s still some kinks to iron out (like objects appearing in front of other objects when they’re supposed to be behind), but for now, it just makes the simulation looks nicer in general. As usual, I’ve added clips of the new rendering system (with 500 planets). I’ll see you in a few days when I’ve added something useful to the project.
Log in to leave a comment
I’ve added few things during the last weeks:
Here’s a video showing the new spawning function in action with 500 planets or so.
Log in to leave a comment
Turns out the simulation wasn’t implemented properly, so that’s fixed. On another note, I’ve added a working camera system! You can now move the camera by using wasd and zoom in/out by pressing the up and down arrows respectively. Additionally, you fix the camera’s position on a planet by pressing “x” and switch the current planet you’re fixed on pressing “n” .
Here’s some other small changes I’ve made to this project:
And that’s everything I’ve added for now, which, i do admit, is very little for almost 10 hours of work, but now that I’ve gotten familiarized with the love2d framework, i hope i can pick up the pace a little bit.
I’ve attached an image showing the solar system simulated in this program as a proof of concept. As you can see, is somewhat inaccurate because I mistyped the some of the planets’ initial velocities and never bothered to fix them.
Log in to leave a comment
Currently, you can spawn new planets with “w”, clear all spawned planets with “c”, pause the simulation with space and show the debug lines by pressing “e”. Hopefully I’ll remember to write all of this in the readme file
Log in to leave a comment