Coding Challenge 180: Falling Sand @TheCodingTrain
Coding Challenge 180: Falling Sand  @TheCodingTrain
Uploaded January 2024 | Updated September 2026, 1 week ago
It's Genuary 2024! Watch as I attempt to build a falling sand simulation in p5.js using a grid of pixels and simple rules. Code: thecodingtrain.com/challenges/180-falling-sand

πŸš€ Watch this video ad-free on Nebula nebula.tv/videos/codingtrain-coding-challenge-180-falling-sand

p5.js Web Editor Sketches:
πŸ•ΉοΈ Falling Sand: editor.p5js.org/codingtrain/sketches/AoH40T6fV
πŸ•ΉοΈ Falling Sand with Gravity: editor.p5js.org/codingtrain/sketches/Ij5i7a3w4

πŸŽ₯ Previous: youtu.be/Ggxt06qSAe4?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ All: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH

References:
πŸ”— Genuary: https://genuary.art/
πŸ”— Sandspiel by Max Bittker: sandspiel.club
πŸ”— Making a falling sand simulator: https://jason.today/falling-sand
πŸ“• The Nature of Code by Daniel Shiffman: natureofcode.com

Videos:
πŸŽ₯ Noita 1.0 Launch Trailer by Nolla Games: youtube.com/watch?v=0cDkmQ0F0Jw
πŸš‚ Wolfram CA: youtu.be/Ggxt06qSAe4
πŸš‚ The Game of Life: youtu.be/FWSR_7kZuYg

Related Coding Challenges:
πŸš‚ 179 Wolfram CA: youtu.be/Ggxt06qSAe4
πŸš‚ 85 The Game of Life: youtu.be/FWSR_7kZuYg
πŸš‚ 107 Sandpiles: youtu.be/diGjw5tghYU
πŸš‚ 132 Fluid Simulation: youtu.be/alhpH6ECFvQ
πŸš‚ 102 2D Water Ripple: youtu.be/BZUdGqeOD0w

Timestamps:
0:00 Introduction and references
2:10 About cellular automata
2:47 The rules for a sand simulation
3:36 Code! Creating a grid
5:04 Animating a falling grain of sand
7:32 About matrix columns and rows
8:04 Let's account for the bottom edge
9:09 Adding mouse interaction
9:42 More sophisticated sand behavior
10:43 Oops! Some errors to fix
11:30 Adding randomness
12:26 Handling left and right edges
14:00 Checking if mouse is within the canvas
14:40 Making it more efficient
14:56 More space and more sand
16:55 Adding some color!
18:54 Challenge complete! Let's do some refactoring
20:58 How could we add gravity?
21:57 Wrapping up

Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound

πŸš‚ Website: thecodingtrain.com
πŸ‘Ύ Share Your Creation! thecodingtrain.com/guides/passenger-showcase-guide
🚩 Suggest Topics: github.com/CodingTrain/Suggestion-Box
πŸ’‘ GitHub: github.com/CodingTrain
πŸ’¬ Discord: thecodingtrain.com/discord
πŸ’– Membership: youtube.com/thecodingtrain/join
πŸ›’ Store: standard.tv/codingtrain
πŸ–‹οΈ Twitter: twitter.com/thecodingtrain
πŸ“Έ Instagram: instagram.com/the.coding.train

πŸŽ₯ Coding Challenges: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ Intro to Programming: youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA

πŸ”— p5.js: p5js.org
πŸ”— p5.js Web Editor: editor.p5js.org
πŸ”— Processing: processing.org

πŸ“„ Code of Conduct: github.com/CodingTrain/Code-of-Conduct

This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecodingtrain.com/issues/new

#pixels #simulation #fallingsand #fluidsimulation #sandpilemodel #generativeart #p5js #javascript
Coding Challenge 180: Falling SandCoding Challenge 171! #shortsMarbling Ink Simulation #javascript #fluidsimulationCoding Challenge 185: Unfolding Fractals16.17: Inheritance in JavaScript - Topics of JavaScript/ES6Coding Challenge #159: Simple Pendulum SimulationAdvent of Code (Side Project Saturday!)Coding Challenge 168: MandelBulb 3D FractalIntegration Test Stream #13.4 Polar Coordinates - The Nature of CodeI, Robot5.4 Arrive Steering Behavior - The Nature of Code
The Coding Train |

Coding Challenge 180: Falling Sand

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER