Let’s Build a Physics Simulation (PONG: Part 1)

  Рет қаралды 10,275

MinuteLabs.io

MinuteLabs.io

Күн бұрын

Join me in building a physics simulation from scratch!
Part 2: • Let’s Build a Physics ...
Start here:
playcode.io
Vector Library URL:
labs.minutelabs.io/toolkit/js...
Finished Product:
playcode.io/642557/
----
Tutorial recommendation for programming beginners:
• JavaScript Tutorial fo...
----
If you get something out of the work I do, consider sponsoring me on either:
Github Sponsors: github.com/sponsors/wellcaffe...
Patreon: / minutelabsio
----
Contents
00:00 Introduction
01:35 Getting Started
03:31 Creating an HTML Canvas
06:48 Drawing a circle
11:47 Color Trick for CodePlay
12:51 Making things move (Animation Loop)
18:43 Getting things smooth (Framerate Adjustment)
21:40 Our first physics equation
24:19 Using Vectors
30:15 Bouncing off the walls (Edge Collisions)
36:51 Cleaning up a bit
39:52 What's to come in Part 2

Пікірлер: 30
@hasifaiman
@hasifaiman 3 жыл бұрын
Dude this is by far the most fun I've ever had doing programming. Kudos 😃 Long time subscriber here btw :-)
@rowansupernova6274
@rowansupernova6274 3 жыл бұрын
I enjoyed watching this and learning JavaScript and code in general, I'm also surprised how much physics is involved in moving an object. loved the video thanks for posting.
@jeffnc
@jeffnc 3 жыл бұрын
Thanks for sharing both the video and the link to the finished product, really fun to follow along and play with the code!
@janwijbrand
@janwijbrand 3 жыл бұрын
Cool! Let's see if I can take my son along for this ride!
@JaX0rton
@JaX0rton 3 жыл бұрын
I've been a professional programmer for over a decade. I have never found it fun to watch someone else code. This video was oddly satisfying. Kudos mate!
@AlthenaLuna
@AlthenaLuna 3 жыл бұрын
This reminds me of the Computerphile videos doing a similar thing (building Pong with Python).
@AlthenaLuna
@AlthenaLuna 3 жыл бұрын
@the cat This is video 1 of 4, the next videos for each should be linked in the description but they're recent enough that they're near the top in their uploads: kzbin.info/www/bejne/gIOvlZWqbNt-Y6c
@naturepositive7707
@naturepositive7707 3 жыл бұрын
Thank you.
@TheBuMHeD
@TheBuMHeD 3 жыл бұрын
Looking forward to part 2!
@user-kr5in9wr1h
@user-kr5in9wr1h 3 жыл бұрын
This is a really helpful video, not just for physics and/or coding experts, but for anyone who is interested in understanding reality. You can get a glimpse of how things actually operate in life. I will quote elon musk on that one. 'Physics is a good framework for thinking. ... Boil things down to their fundamental truths and reason up from there.'
@igoregalado5590
@igoregalado5590 3 жыл бұрын
I have always wanted to successfully make a program, so I started learning HTML for 3 months then stopped because I realized this was not the right language. Next, I learned JavaScript for 5 months then stopped again because I wanted to make a program, not something on a website. Finally, here I am, for 4 months and counting trying to learn Java. I'm on my way. I've been through the pain, I'll get there. Someday. This is a very nice video though, gotta say that.
@Gaspa79
@Gaspa79 3 жыл бұрын
You have nodejs for javascript which will let you code basically anything in javascript, in case you're interested
@shashankchandra1068
@shashankchandra1068 2 жыл бұрын
Plz simulate concepts in physics too
@soufianedev1447
@soufianedev1447 3 жыл бұрын
Thank you
@vikassrivastava2680
@vikassrivastava2680 3 жыл бұрын
This is fantastic. I have been wanting to do something like this for quite some time. Thanks a lot. Eagerly waiting for part 2. Also, would love to see F=ma and equations of motion being used sometime in code. Would love to see if those equations can be handled by Vector math using the library that you shared
@Minutelabsio
@Minutelabsio 3 жыл бұрын
We will get to more physics equations in future projects. Stay tuned!
@vikassrivastava2680
@vikassrivastava2680 3 жыл бұрын
@@Minutelabsio Right now I am trying to write a ball drop java script. I am starting with zero initial velocity and some acceleration (just like acceleration due to gravity) and using equations of motion, computing position and velocity at every delta time. Let me know if there is any was of sharing my code for collaboration and you can see if I am missing something. I want to learn alongside having fun.
@Minutelabsio
@Minutelabsio 3 жыл бұрын
@@vikassrivastava2680 Great that you're playing around with this. I'm actually going to cover acceleration in another video. There is a bit more to say about it than I can write in a comment, but don't worry I'll cover that soon. For now, try just changing the velocity every timestep: velocity.add(acceleration.times(dt))
@vikassrivastava2680
@vikassrivastava2680 3 жыл бұрын
@@Minutelabsio Great, I will wit for those videos. In the meantime here is what I am doing function moveCircle() { // compute the position based on equation of motion // s = ut + (1/2) * a * t^2 ball.position.add(ball.velocity.times(dt)); ball.position.add(ball.acceleration.times(0.5).times(dt).times(dt)); ball.velocity.add(ball.acceleration.times(dt)); }
@ultrio325
@ultrio325 3 жыл бұрын
I'm trying to learn oop so I'm doing this and trying to implement an object system at the same time
@Minutelabsio
@Minutelabsio 3 жыл бұрын
Do you have any questions or confusions about coding interactives? I'll try my best to answer what I can in the comments. If you have suggestions for future topics please let me know! And don't forget to post your versions of PONG! If you get something out of the work I do, consider sponsoring me on either: Github Sponsors: github.com/sponsors/wellcaffeinated Patreon: www.patreon.com/minutelabsio
@discreet_boson
@discreet_boson 3 жыл бұрын
This is epic
@LKDesign
@LKDesign 3 жыл бұрын
The _Jeff Goldblum_ of, uh, coding.
@usama57926
@usama57926 3 жыл бұрын
14:40 Why don't you use *setInterval* instead of *setTimeout* ❓❓❓
@Minutelabsio
@Minutelabsio 3 жыл бұрын
Great question. Currently, they would do the same thing, you're right. But it's possible to have `dt` change during the animation. The reason for this would be that sometimes doing smaller steps gives better accuracy, and sometimes that affects the physics. That would be difficult to do with `setInterval`.
@user-dg6pl4pf3f
@user-dg6pl4pf3f 8 ай бұрын
저도 이런 것을 만들고 싶습니다! 그저 꿈이지만요
@usama57926
@usama57926 3 жыл бұрын
19:56 Are use using variable name *dt* as little change in time. Just like we do in *derivatives (dx, dy)* ....❓❓❓
@Minutelabsio
@Minutelabsio 3 жыл бұрын
Yes!
@caynebyron
@caynebyron 3 жыл бұрын
If you've got a problem with semi-colons then you've got a problem with me and I suggest you let that one marinate.
@Minutelabsio
@Minutelabsio 3 жыл бұрын
I used to be like you
Let’s Build a Physics Simulation (PONG: Part 2)
1:07:23
MinuteLabs.io
Рет қаралды 2,5 М.
where is the ball to play this?😳⚽
00:13
LOL
Рет қаралды 14 МЛН
Последний Закат Кота Макса...
00:21
Глеб Рандалайнен
Рет қаралды 4,7 МЛН
Зомби Апокалипсис  часть 1 🤯#shorts
00:29
INNA SERG
Рет қаралды 7 МЛН
A* Pathfinding Algorithm (Coding Challenge 51 - Part 1)
48:42
The Coding Train
Рет қаралды 3,3 МЛН
“Hello, world” from scratch on a 6502 - Part 1
27:25
Ben Eater
Рет қаралды 4,6 МЛН
Coding Adventure: Chess
29:22
Sebastian Lague
Рет қаралды 3,7 МЛН
17 - How to write an Eulerian fluid simulator with 200 lines of code.
12:05
Ten Minute Physics
Рет қаралды 274 М.
Simulating Lifespan (Why do blobs die around age 2?)
9:33
MinuteLabs.io
Рет қаралды 158 М.
I programmed some creatures. They Evolved.
56:10
davidrandallmiller
Рет қаралды 4 МЛН
This lab took me 6 years to release
3:25
MinuteLabs.io
Рет қаралды 11 М.
Interactive Evolution Simulator
11:22
MinuteLabs.io
Рет қаралды 207 М.
Эффект Карбонаро и бумажный телефон
1:01
История одного вокалиста
Рет қаралды 2,4 МЛН
A4 Reset to zero
0:26
STYLE YT
Рет қаралды 17 М.
Wow AirPods
0:17
ARGEN
Рет қаралды 1 МЛН
Save Work Efficiently on Your Computer 18/05/2024
0:51
UNIQUE PHOTO EDITING
Рет қаралды 308 М.
wyłącznik
0:50
Panele Fotowoltaiczne
Рет қаралды 12 МЛН