Gravity simulation

Gravity simulation

11 devlogs
13h 53m
•  Ship certified
Created by Fire coin

Simulates simple gravity of objects floating in space. Whole program is written in python tkinter. It supports dynamic addition, deletion and modification of bodies, also with copying them.
PS. the recorded time is quite high, because I spent a lot of time testing and correcting different errors, because I wanted to make it without AI.

Timeline

Added default objects: all 8 planets, Sun and Moon.

Update attachment

Ship 1

1 payout of shell 165.0 shells

Fire coin

about 1 year ago

Fire coin • Covers 10 devlogs and 12h 3m

Tested different ways to render objects on canvas, and stick with the one that worked the best. Also in readme in repository added tutorial to compile python file into executable. And removed those 4 static objects from simulation.

Update attachment

Added help button.

Update attachment

Added modification of already placed object, now if already placed object is clicked, the menu will pop up and show that info about it. Also added option to change center in pop up menu. And lastly, now it is possible to copy selected objects by pressing c key.

Update attachment

Added info menu in top right corner of canvas. It displays the scale of simulation, and if it is running or paused.

Update attachment

I split the code into different files, also removed simulation toggle button and binded space bar to toggle simulation.

Update attachment

Added dynamic addition of bodies. When canvas is left clicked, new body is 'created' and its attributes can be changed, to see change to take action you need to press Enter key, and to create the body, so it will be simulated along with other bodies, you need to press left Alt. Also by pressing right mouse button you can delete the previewed body. Following attributes can be changed: mass, radius, color, x component of velocity vector, y component of velocity vector.

Update attachment

Added start / pause button under the canvas. Also changed background to black.

Added gravitation pull between objects. Also encountered bug with tags in tkinter canvas, and spent around hour fixing it. Currently you can add objects only from code statically, not by clicking mouse.

Now I am able to add objects into the game, they are simple structures with mass, radius, color, center and velocity data members. Velocity is not implemented yet. And radius and center of object have to be scaled by 1e10, because that is default scale of the game, this is done for better accuracy.

Update attachment

Set up game screen and basic game loop alongside with option to leave by pressing Esc key.

Update attachment