Particle Systems with Inheritance
Nature of Code Lesson #4.3
Have you ever wondered how the concepts of inheritance and polymorphism fit into the Nature of Code Particle system examples in p5.js?
Topics
- 0:00 - Hi!
- 0:27 - Code! Make particle extend p5.Vector.
- 1:23 - Code! Let's make a class that extends Particle.
- 2:52 - Whoops! Javascript file order matters, sometimes.
- 3:26 - Code! We need to use the Confetti class.
- 4:00 - Code! What if we want both confetti and particles.
- 4:32 - Ideas! Some exercises you could try.
- 4:47 - Discuss! When might you want to extend a class?
- 5:52 - What's next?
Community Contributions
- Secret Contributution by Indrayudh Chakraborty (Source Code)
- Opposite Particles System by Indrayudh Chakraborty (Source Code)
- Electric Sparks by Krishanth (Source Code)
- Recursive Explosions by LemurDaniel (Source Code)
- Burning torch by wojtekpaszo (Source Code)
- Boxy fire by wojtekpaszo (Source Code)
- Firecracker by Dong-Gkyun Yang (Source Code)
You can also add your own version! (See how)
Videos discussed in this lesson
- Inheritance in JavaScript by The Coding Train
- Polymorphism in JavaScript by The Coding Train