Products
Features
YouTube Video Summarizer
Summarize YouTube videos
Web & PDF Highlighter
Highlight web pages & PDFs
Chat with PDF
Ask any PDF questions with AI
Ask AI Clone
Chat with your highlights & memories
Audio Transcriber
Transcribe audio files to text
Glasp Reader
Read and highlight articles
Kindle Highlight Export
Export your Kindle highlights
Idea Hatch
Hatch ideas from your highlights
Integrations
Obsidian Plugin
Notion Integration
Pocket Integration
Instapaper Integration
Medium Integration
Readwise Integration
Snipd Integration
Hypothesis Integration
Apps & Extensions
Chrome Extension
Safari Extension
Edge Add-ons
Firefox Add-ons
iOS App
Android App
Discover
Discover
Ideas
Discover new ideas and insights
Articles
Curated articles and insights
Books
Book recommendations by great minds
Posts
Essays and notes from readers
Quotes
Inspiring quotes collection
Videos
Curated videos and summaries
Explore Glasp
Glasp Story
How we grew from 0 to 3 million users
Glasp Newsletter
Weekly insights and updates
Glasp Talk
Interview series with great minds
Glasp Blog
Latest news and articles
Glasp Use Cases
Learn how others use Glasp
Build & Support
Glasp API
Access Glasp's API for developers
MCP Connector
Connect Glasp to Claude & ChatGPT
Community
Glasp Reddit Community
Students
Student discount and benefits
FAQs
Frequently Asked Questions
AboutPricing
DashboardLog inSign up

4.3: Particle Systems with Inheritance - The Nature of Code

35.5K views
•
April 1, 2021
by
The Coding Train
YouTube video player
4.3: Particle Systems with Inheritance - The Nature of Code

TL;DR

This video explores the concepts of inheritance and polymorphism in particle systems, demonstrating how to create different types of particles using classes and extending existing classes.

Transcript

Hi, so I'm expecting-- I don't know if this is true-- for you to have watched my videos about inheritance and polymorphism before watching this one. It's fine if you didn't. Maybe this will be useful to you. Maybe you already know about inheritance and polymorphism. But I am basically going to take those concepts from those videos and apply it to t... Read More

Key Insights

  • 👻 Extending classes allows for code reusability and maintains a hierarchical relationship between objects.
  • ❓ Inheritance in JavaScript can be achieved by using the "extends" keyword.
  • 👻 Overriding functions in child classes allows for customization and the ability to alter the behavior of inherited functions.
  • 🏛️ The order of JavaScript files in an HTML page can impact the recognition of classes when they extend each other.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: How does extending the p5.Vector class benefit the particle object?

By extending the p5.Vector class, the position vector is embedded within the particle object, eliminating the need for a separate position variable and allowing access to all the functionalities of p5.Vector.

Q: What is the purpose of the Confetti class?

The Confetti class extends the particle class and introduces the concept of an angle and a custom Show function, providing a different way to draw the Confetti particle while inheriting all other functionalities from the particle class.

Q: Why does the order of JavaScript files matter when it comes to inheritance?

In JavaScript, when a class extends another class, the parent class needs to be recognized before the child class. Therefore, if a child class is defined before the parent class in the HTML page, it won't know what the parent class is.

Q: When should you create a new class that extends an existing class instead of adding modifications to the original class?

It depends on the level of modification needed. If you only need to add a few properties or functionalities, it might be better to modify the original class. However, if you want to completely change the behavior or appearance of an object, creating a new class that extends the parent class is more appropriate.

Summary & Key Takeaways

  • The video introduces the idea of extending the p5.Vector class for the particle object, allowing the position vector to be embedded within the particle.

  • A new class called Confetti is created, which extends the particle class and adds the concept of an angle and a custom Show function.

  • The order of JavaScript files in the HTML page matters when it comes to inheritance, and the particle class needs to be defined before the Confetti class.

  • The video demonstrates how to add both particle and Confetti objects randomly to the particle system, and suggests an exercise to add a third class that extends particle.


Read in Other Languages (beta)

English

Share This Summary 📚

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Explore More Summaries from The Coding Train 📚

Coding Challenge #116: Lissajous Curve Table thumbnail
Coding Challenge #116: Lissajous Curve Table
The Coding Train
Computer Mouse Conference Demos! (node.js + tensorflow.js) thumbnail
Computer Mouse Conference Demos! (node.js + tensorflow.js)
The Coding Train
Classifying Poses with ml5.js Part 2 thumbnail
Classifying Poses with ml5.js Part 2
The Coding Train
9.4: Genetic Algorithm: Looking at Code - The Nature of Code thumbnail
9.4: Genetic Algorithm: Looking at Code - The Nature of Code
The Coding Train
8.1: Fractals - The Nature of Code thumbnail
8.1: Fractals - The Nature of Code
The Coding Train
How to Create Fractal Patterns with Toothpicks thumbnail
How to Create Fractal Patterns with Toothpicks
The Coding Train

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Apps & Extensions

  • Chrome Extension
  • Safari Extension
  • Edge Add-ons
  • Firefox Add-ons
  • iOS App
  • Android App

Key Features

  • YouTube Video Summarizer
  • Web & PDF Summarizer
  • Web & PDF Highlighter
  • Chat with PDF
  • Ask AI Clone
  • Audio Transcriber
  • Glasp Reader
  • Kindle Highlight Export
  • Idea Hatch

Integrations

  • Obsidian Plugin
  • Notion Integration
  • Pocket Integration
  • Instapaper Integration
  • Medium Integration
  • Readwise Integration
  • Snipd Integration
  • Hypothesis Integration

More Features

  • APIs
  • MCP Connector
  • Blog & Post
  • Embed Links
  • Image Highlight
  • Personality Test
  • Quote Shots
  • Open Graph Checker

Company

  • About us
  • Our Story
  • Blog
  • Community
  • FAQs
  • Job Board
  • Newsletter
  • Pricing
Terms

•

Privacy

•

Guidelines

© 2026 Glasp Inc. All rights reserved.