1 - Erase 2 - Place sand 3 - Place water 4 - Place ash
This is a fast sand physics simulation in Scratch. Optimizations used: - Partial rendering: Only particles that change are re-rendered on each frame. - Update queue: Only the particles that need updating are added to a queue for the next frame. - Update set: There is an update set, speeding up checking if a particle is already in the queue. - Two update queues: There are actually 2 update queues (and 2 sets). One queue is scanned while updates are added to the other, then it swaps. - Queueing fewer updates: When a sand particle falls, only the positions above its old position, as well as the new position itself, are actually queued. - Queueing even fewer updates: Extra checking is used to only queue particles that will actually want to move. - No edge checking: Impenetrable walls replace the need to check against the edges.