ScratchData LogoScratchData
Back to rdococ's profile

Grid-based Gravity Sim

RDrdococ•Created August 25, 2024
Grid-based Gravity Sim
15
14
116 views
View on Scratch

Instructions

Press [Z], [X] and [C] to switch between the grid and brute-force methods. In (alt)grid mode, you can hold down the mouse to generate gravity and direct points. Press [G] to switch between default and simple graphics. The simple graphics mode offers a small performance boost. Move the mouse to the top of the screen to see parameters you can adjust.

Description

Gravity simulation based on a flat grid. Performance is significantly better than Barnes-Hut algorithm on Scratch, with 500 particles simulating at full speed, but accuracy is reduced. - `grav.in` is updated to include the combined mass of each particle in each cell. - `grav.x`, `grav.y` are updated to include the combined gravitational influence of other cells. - Then, particles are accelerated & moved based on the gravitational influence in their cell. `AltGrd` mode is similar to `Grid` mode, but the grid is offset on alternating frames to improve accuracy at minimal performance cost. The visualization for this mode is a work-in-progress. (Also, for some reason, brute-force mode with friction looks almost... alive. But you'll need to try it in TurboWarp)

Project Details

Project ID1059246565
CreatedAugust 25, 2024
Last ModifiedJune 7, 2025
SharedAugust 25, 2024
Visibilityvisible
CommentsAllowed