New to Coding? START HERE
Retake this course?
Retaking this course from the beginning will reset all of your tracked progress.
Let’s Practice What You Learned!
Crave for more creative juices? Join us!
Start with our Creative Coding Math toolkit! Check your email for a link to download.
🔗 Code Example: Collisions Without a Physics Library!
🔗 References:
p5.js 2.0
matter.js playlist
Quadtree Tutorial
The Coding Train’s Collision Without a Physics Library Tutorial
🔗 Resources:
3Blue1Brown’s video on Dot Products
🔗 Timestamps:
01:23 Approach
04:07 Use p5.js 2.0 and create a bouncing ball
08:08 Create a Ball class
17:17 Collide function - Step 1: Check if balls collide & Step 2: Correct their positions
24:08 Collide function - Step 3: Calculate new velocities
31:24 Create multiple Ball objects
34:39 Write a sleep method when ball is at rest (pushing effect)
38:27 Draw eyes and mouth and add colors!
46:18 Remove objects that are off the screen
50:50 Add some typography
57:22 Vary text weights for animation