Coding Challenge 180: Falling Sand
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: https://thecodingtrain.com/challenges/180-falling-sand
π Watch this video ad-free on Nebula https://nebula.tv/videos/codingtrain-coding-challenge-180-falling-sand
p5.js Web Editor Sketches:
πΉοΈ Falling Sand: https://editor.p5js.org/codingtrain/sketches/AoH40T6fV
πΉοΈ Falling Sand with Gravity: https://editor.p5js.org/codingtrain/sketches/Ij5i7a3w4
π₯ Previous: https://youtu.be/Ggxt06qSAe4?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ All: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
References:
π Genuary: https://genuary.art/
π Sandspiel by Max Bittker: https://sandspiel.club/
π Making a falling sand simulator: https://jason.today/falling-sand
π The Nature of Code by Daniel Shiffman: https://natureofcode.com/
Videos:
π₯ Noita 1.0 Launch Trailer by Nolla Games: https://www.youtube.com/watch?v=0cDkmQ0F0Jw
π Wolfram CA: https://youtu.be/Ggxt06qSAe4
π The Game of Life: https://youtu.be/FWSR_7kZuYg
Related Coding Challenges:
π 179 Wolfram CA: https://youtu.be/Ggxt06qSAe4
π 85 The Game of Life: https://youtu.be/FWSR_7kZuYg
π 107 Sandpiles: https://youtu.be/diGjw5tghYU
π 132 Fluid Simulation: https://youtu.be/alhpH6ECFvQ
π 102 2D Water Ripple: https://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: https://thecodingtrain.com/
πΎ Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide
π© Suggest Topics: https://github.com/CodingTrain/Suggestion-Box
π‘ GitHub: https://github.com/CodingTrain
π¬ Discord: https://thecodingtrain.com/discord
π Membership: http://youtube.com/thecodingtrain/join
π Store: https://standard.tv/codingtrain
ποΈ Twitter: https://twitter.com/thecodingtrain
πΈ Instagram: https://www.instagram.com/the.coding.train/
π₯ Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
π p5.js: https://p5js.org
π p5.js Web Editor: https://editor.p5js.org/
π Processing: https://processing.org
π Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecodingtrain.com/issues/new
#pixels #simulation #fallingsand #fluidsimulation #sandpilemodel #generativeart #p5js #javascript
Other Videos By The Coding Train
2024-07-31 | ml5.js 1.0 and Guest Conductor Patt Vira |
2024-07-30 | Use code CHOOCHOO for 25% off. Pre-ordering direct from me comes with a bonus bookmark and sticker! |
2024-07-13 | Collisions Without a Physics Library! (Coding Challenge 184) |
2024-07-01 | i like pink |
2024-05-16 | Marbling Ink Simulation #javascript #fluidsimulation |
2024-05-02 | Coding Challenge 183: Paper Marbling Algorithm |
2024-03-24 | Passenger Showcase and Building a Creative Coding AI Agent? |
2024-03-14 | Coding Challenge 182: Apollonian Gasket Fractal |
2024-02-22 | Coding Challenge 181: Weighted Voronoi Stippling |
2024-02-02 | I, Robot |
2024-01-22 | Coding Challenge 180: Falling Sand |
2024-01-20 | Flocking rule 4? #genuary19 |
2024-01-18 | #genuary18 Bauhaus |
2024-01-16 | #genuary16 10,000 snowflakes |
2024-01-15 | #genuary15 physics library! |
2024-01-14 | Lava Lamp #genuary #genuary12 |
2024-01-10 | Hexagonal Cellular Automata #genuary10 #genuary |
2024-01-09 | #genuary9 |
2024-01-09 | Coding Challenge 179: Elementary Cellular Automata |
2024-01-08 | Chaotic System #genuary8 |
2024-01-07 | Throbber #genuary7 |