4.1: while and for Loops - p5.js tutorial

  Рет қаралды 214,367

The Coding Train

The Coding Train

Күн бұрын

Пікірлер: 180
@acinaces343
@acinaces343 4 жыл бұрын
I don’t know anyone else who smiles this much while coding
@jovem3767
@jovem3767 3 жыл бұрын
Brackeys:)
@jimmybuck1993
@jimmybuck1993 4 жыл бұрын
It's not that you're just good at explaining, it's that you're good a at inspiring ideas.
@lbruinsl5553
@lbruinsl5553 25 күн бұрын
its been almost 10 yrs since these were made, im watchin in 24/25, and they are great. He is so energetic its easy to watch
@GraceandWisdom
@GraceandWisdom 4 жыл бұрын
Daniel, if everybody else were as clear and understandable as you, our nations might have world peace at last!!!
@cristaldominguez1834
@cristaldominguez1834 5 жыл бұрын
Omg you are so good at explaining things I’m recommending to anyone who needs these tutorials
@ciceroaraujo5183
@ciceroaraujo5183 4 жыл бұрын
And you are really beautiful
@alejojandro21
@alejojandro21 4 жыл бұрын
@@ciceroaraujo5183 what the Fuck
@Aryaman_Agarwal
@Aryaman_Agarwal 4 жыл бұрын
@@ciceroaraujo5183 no i don't think so
@Aryaman_Agarwal
@Aryaman_Agarwal 4 жыл бұрын
@@ciceroaraujo5183 not my type
@TanishFX
@TanishFX 2 жыл бұрын
@@Aryaman_Agarwal And no one asked you? Find the defintion of a "opinion"
@persenbp4160
@persenbp4160 4 жыл бұрын
you are an incredible and passionate teacher who makes even boring stuffs look really really really interesting ! i resolved to make this comment every time i watch your vid comment 2/x
@akhilkashyep
@akhilkashyep 9 жыл бұрын
Hi Daniel! Nice tutorials. Loved your way of presenting them with a smile. Keep it on. Also you keep on asking if any one would watch them...let me tell you I am watching them for last 4+ hours. :)
@TheCodingTrain
@TheCodingTrain 9 жыл бұрын
+Akhil Kashyap oh, i am so glad to hear that thank you!
@TalismanTeaches
@TalismanTeaches 5 жыл бұрын
@@TheCodingTrain i have been watching for about 4 hrs
@josephs482
@josephs482 4 жыл бұрын
@@TheCodingTrain after 5 years, i'm still watching these nonstop. You are the greatest teacher!
@tahaozalozkan5901
@tahaozalozkan5901 7 жыл бұрын
U're the best teacher i've ever seen. I wish all the best for you from Turkey!!!
@TheCodingTrain
@TheCodingTrain 7 жыл бұрын
Thanks so much!
@hanf4415
@hanf4415 7 жыл бұрын
I've been lost this whole time between for loop and while loop. Thank you for explaining it to us so clearly.
@TheCodingTrain
@TheCodingTrain 7 жыл бұрын
So glad to hear!
@chaios
@chaios 3 жыл бұрын
Thanks. I have watched a lot of lessons regarding for and while loops, but yours is the most concise and easiest to understand.
@AntonioRibeiro-qs3fy
@AntonioRibeiro-qs3fy 5 жыл бұрын
This guy's teaching style is brilliant and i can totally see why its worthwhile showing us the while loop. It help me understand the concept of for loops so much more clearly..I bookmarked the page and subscribed to the channel...I am officially on the coding train :)
@TheCodingTrain
@TheCodingTrain 5 жыл бұрын
Welcome! Choo choo!
@poojabennabhaktula4883
@poojabennabhaktula4883 5 жыл бұрын
I respect you 3000 . Best Teacher on the planet!
@Mo0n1111
@Mo0n1111 Жыл бұрын
Tahnk you so much for doing these videos, I gave it a shot using the map() funct + for loop. Early days, slow progress but enjoying the train ride! function setup() { createCanvas(600, 400); } function draw() { noStroke(); background(220); var minCol = color(51,59,53); var maxCol = color(137,156,142); for (var x = 0; x
@mediafilms1169
@mediafilms1169 9 жыл бұрын
You saving my LIFE... thank you soo much... regards from Germany ;)
@TheCodingTrain
@TheCodingTrain 9 жыл бұрын
+Sinan S thanks for watching!
@Muffin--Man
@Muffin--Man Жыл бұрын
Another great video, here is my code for 13:10 function setup() { createCanvas(400, 400); } function draw() { background(220); let x1=20; while(x1
@randmorf
@randmorf 5 жыл бұрын
About 11:25 into the video, line number "17" is highlighted in yellow because the IDE is issuing a warning that the variable "x" has already been declared. To read the actual warning message, just click on the yellow highlighted line number and the text will appear in a little pop-up text box. To correct this warning, remove "var" from within the for loop's argument list, like so: for (x = 0; x < width; x = x + 50) { You should find that this fix will make the warning go away. I'm sure Dan knows about this, but didn't want to waste time talking about this small detail in order to keep his video short (under 10 minutes).
@saaqib_0252
@saaqib_0252 4 жыл бұрын
best teacher in whole world
@snimerjotsingh5561
@snimerjotsingh5561 4 жыл бұрын
Your videos are really very very helpful. I was lagging in this topic for weeks you cleared it. Appreciated it good work. regards from India.
@stodsy2783
@stodsy2783 9 жыл бұрын
Hi Dan, I've thoroughly enjoyed all your videos and my javascript is rapidly improving. Thanks so much for all your efforts and great job sir!
@TheCodingTrain
@TheCodingTrain 9 жыл бұрын
+Sean Stoddart so glad to hear!
@stan8966
@stan8966 6 жыл бұрын
best programming tutorial ive ever seen!!!!
@goldthumb
@goldthumb 2 жыл бұрын
It's still the last day of 2022 (Toronto). This series is still the best I found for learning JavaScript and p5js.
@krunchan
@krunchan 5 жыл бұрын
You are the jesus of p5.js saving everyones life
@FredoCorleone
@FredoCorleone 6 жыл бұрын
Worth mentioning that there's also a shorthand *++i* . Which differs from *i++* because if you have *++i* in an expression *i* is first incremented and only after evaluated.
@johnyepthomi892
@johnyepthomi892 5 жыл бұрын
Prefix and postfix operator. He probably didn't mention cuz it may just overwhelm beginners.
@madsadolfsen406
@madsadolfsen406 3 жыл бұрын
@@johnyepthomi892 yup
@madsadolfsen406
@madsadolfsen406 3 жыл бұрын
@@johnyepthomi892 I'm overwhelmed
@karenpoveda29
@karenpoveda29 5 жыл бұрын
I love your way of explaining, and also the format of your video, very unique and useful for the explanaition
@ciceroaraujo5183
@ciceroaraujo5183 4 жыл бұрын
You are the best professor.
@ezangrobotsvideos9286
@ezangrobotsvideos9286 4 жыл бұрын
All great stuff, please keep it coming, learning a lot, thanks
@anastasiosvogiatzis92
@anastasiosvogiatzis92 7 жыл бұрын
You, are one of the greatest teachers i've ever had! The best in the internet so far and the best in coding :) Back to learning for me. through you.. to make the world a better place... what? o.O -Its nothing.
@kimchimang
@kimchimang 7 жыл бұрын
Thank you for making the content understandable for beginners! You did an amazing job of it.
@leadlime29
@leadlime29 4 жыл бұрын
the willpower of this man to not use += or ++ until this video
@fear_less_2020
@fear_less_2020 2 жыл бұрын
You simplify everything so well. Hats off, Dan! I wanna be a professor too. I am inspired by you a lot!
@TonyFlexPromo
@TonyFlexPromo 8 жыл бұрын
Thank you so much for making these video tutorial. They are absolutly brilliant. After some other online courses and tutors you are the best.
@bolddiamond
@bolddiamond 2 жыл бұрын
You're amazing!!! Thank you for sharing this
@sadhlife
@sadhlife 7 жыл бұрын
dude, I LOVE the while loop. When the condition in the for loop in not constant, it can lead to really weird errors (array index out of range, etc.) while loop is perfect in those cases.
@jeffreychen6591
@jeffreychen6591 7 жыл бұрын
Thank you. You saved me from the volcano of confusion
@michaelsakowicz718
@michaelsakowicz718 2 жыл бұрын
Incredible! You have helped teach for and while in such a simple and wonderful way! Thank you !
@walker2683
@walker2683 6 жыл бұрын
Thank you for helping me. This made me understand loops now thank you
@Alebtong1
@Alebtong1 7 жыл бұрын
Very good explanation. I am th e dumbest guy in coding and you just made me an expert!
@Iamzercool
@Iamzercool 7 жыл бұрын
your the best teacher, make me easy to learn :) regards from India
@dawitmulugeta7656
@dawitmulugeta7656 4 жыл бұрын
wow,what a nice presentation, all the question i have about loops solved,,,,,keep smiling
@StringCheeseINC
@StringCheeseINC 6 жыл бұрын
Awesome tutorials! Your teaching method is crystal clear - I've learned a ton over the past couple of days. Thanks for sharing your knowledge.
@frownless
@frownless 6 жыл бұрын
i wish this guy was my professor in college
@rishitaggarwal3634
@rishitaggarwal3634 5 жыл бұрын
you have saved me by allowing me to revise my basics!!
@OfficialChoiceTV
@OfficialChoiceTV 7 жыл бұрын
You are an excellent teacher! Thank you for taking the time. I’ve subscribed and will continue to explore your videos! 🙏
@mikegogl
@mikegogl 5 жыл бұрын
This is insane. Thank you Daniel!
@fracasj
@fracasj 4 жыл бұрын
This was SO helpful! I appreciate your explanations. You made this so much easier to understand! Thank you!
@adambreslin6525
@adambreslin6525 3 жыл бұрын
I was just wondering where the width element came from when you were writing your while loop. I thought you would need to create a variable for that word "width" and assign it a value. Is it apart of the p5.js library, and that's why you can use it? Just need to understand that part. @The Coding Train
@安泓仑
@安泓仑 2 жыл бұрын
谢谢!
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Thank you for the support!
@joesteer311
@joesteer311 8 жыл бұрын
Dan these videos are great! Love your teaching style, I'm learning a tonne.
@dava3412
@dava3412 4 жыл бұрын
awsome! you get me through my programming module :D Really comprehensive
@Errrrrr12
@Errrrrr12 6 жыл бұрын
If for loops are best practice than why do they teach while loops? Also var is now replaced by let correct? So is let now best practices other than var? Sorry I am new and get confused because classes I’m taking still use var but I hear should be Let now.
@MrSevenEleven
@MrSevenEleven 9 ай бұрын
you can center by using "height / 2" for the y value instead of 200, it's better than hardcoding it IMO
@kevinskayro
@kevinskayro 5 жыл бұрын
love your videos man, you're awesome
@markus_knoedel
@markus_knoedel 3 жыл бұрын
Still after some time now this is so helpful.
@sindhu023
@sindhu023 4 жыл бұрын
What is the closed caption at 1:03????
@mmbower1
@mmbower1 4 жыл бұрын
'if' transfers to 'while' well. Glad you confirmed that.
@sweethomes674
@sweethomes674 Жыл бұрын
Excellent explanations 😊
@maryemguizani5959
@maryemguizani5959 5 жыл бұрын
Thank you so much for this amazing video ! U SAVED MY LIFE !
@smmakhan5401
@smmakhan5401 5 жыл бұрын
Waooo teaching style is very impressive
@viv_tech5660
@viv_tech5660 4 жыл бұрын
How would use the for loo[p if u wanted to code in a parallelogram by using the "quad" function.
@marcomcl
@marcomcl 4 жыл бұрын
Amazing tutorial!! Loved it!!
@masonictraveler6558
@masonictraveler6558 2 жыл бұрын
Amazing teaching!
@deepjyotikachakrabarti8520
@deepjyotikachakrabarti8520 4 жыл бұрын
what if the shape has multiple x coordinates like triangle . How will loop will help to get a geometric pattern?
@klaygh3106
@klaygh3106 5 жыл бұрын
GOd bless your life with Grace. you are doing best
@diwashkuskusmiya8668
@diwashkuskusmiya8668 4 жыл бұрын
I love u r smile and I enjoy your fun learning
@emanuel3617
@emanuel3617 3 жыл бұрын
This... this guy is making me learn and... And I am enjoying it!!! >:0 what is this dark magic that makes me get exited with numbers!?
@MrKasikannan2000
@MrKasikannan2000 4 жыл бұрын
do u know how to make it come vertically instead of horizontal
@rituchandra6325
@rituchandra6325 5 жыл бұрын
no body loves the *do while* loop... XD EDIT: your videos are very helpful, i am able to learn new things about programming!! please keep up the good work
@shaksto
@shaksto 3 жыл бұрын
Hello Mr Daniel, I am having a problem. When I try using the command 'while' the entire tab just lags out. Any tips on what I should do?
@Watchman-Michael
@Watchman-Michael 6 ай бұрын
Briliant, thank you. bless you
@bm_pug
@bm_pug 7 жыл бұрын
You will help me pass my exams next month. Thank you sempai -_-
@tristanhurley9071
@tristanhurley9071 5 жыл бұрын
Why ints in the brackets? Process i get, not sure what ints do though..
@utavtakt9361
@utavtakt9361 4 ай бұрын
When I add while (x < width) Google chrome crashes? X)
@yukfu8665
@yukfu8665 5 жыл бұрын
"A 'for loop' consists of three different expressions inside of a parenthesis, all of which are optional. These expressions are used to control the number of times the loop is run. The first expression is a statement that is used to set the initial state for the loop. The second expression is a condition that you would like to check before each loop. If this expression returns false then the loop will exit. The third expression is executed at the end of each loop."
@KeyCode98347
@KeyCode98347 2 жыл бұрын
thanks! that cleared that up for me.
@BusyAsBee1738
@BusyAsBee1738 4 жыл бұрын
question: why does the var x have to be in draw function for code to work? i tried making it global variable but results went eee orw
@leozzl1310
@leozzl1310 6 жыл бұрын
hi! I get some error. Uncaught ReferenceError: loopProtect is not defined (sketch: line 12) can somebody help?
@billyzman666
@billyzman666 3 жыл бұрын
Thank you so much! This is very helpful.
@KhanleGrand
@KhanleGrand 5 жыл бұрын
What a wonderful video. Well explained.
@georgesfarkouh6271
@georgesfarkouh6271 7 жыл бұрын
Hi, why when declare x as a local variable in draw function and we then add 50 the operation happen once and when we declare x as global variable 50 is added to x continuously (x+50=100, 100+50=150, ..... ) so when we run it we got a moving ball.
@cawa7787
@cawa7787 7 жыл бұрын
I know this is a while ago, but the reason this happens is that when you declare it in draw then add 50 to it in draw, it keeps looping. The effect of this means that first x is set to 0 (or the number you started with), then 50 is added to it. Then when the draw function starts again, it resets x to 0, then adds 50 again. This then happens forever.
@shashidhara.g.m655
@shashidhara.g.m655 5 жыл бұрын
He: someone or no one might be watching this video Every 85k viewers : 0-0
@pedrofelix5846
@pedrofelix5846 5 жыл бұрын
You did a great job explaining this concept thank you
@samueljaramillo7144
@samueljaramillo7144 4 жыл бұрын
dude, you are hilarious. and excellent, big thank you!
@singingmermaid4338
@singingmermaid4338 Жыл бұрын
hey I'm a beginner and a little bit confused what the width means here ( if x < .... ) is with width the width of the canvas meant? or the width of the ellipse? helppppp haha
@TheCodingTrain
@TheCodingTrain Жыл бұрын
You can come and ask your questions and get help in the discord! It's a little hard to do in KZbin comments: thecodingtrain.com/discord
@jordiyaputra8359
@jordiyaputra8359 7 жыл бұрын
Hello, Sir... Is there anyway to use break; or continue; to stop looping?
@marwa-zr8vk
@marwa-zr8vk 5 жыл бұрын
best programming tut
@krishnakumar-hm9ce
@krishnakumar-hm9ce 4 жыл бұрын
i think u should join white hat jr because i m a white hat jr student and i didnt under stand this for loop in my class but u explain it very well
@lucykim513
@lucykim513 3 жыл бұрын
he looks so enthusiastic for the boringest shit ever. thanks though this helped quite alot
@extendedreal
@extendedreal 5 жыл бұрын
Why is this not working for me?? It says “Invalid left hand sign in assignment”. I copied your format but it still shows up
@LyGr05
@LyGr05 5 жыл бұрын
can mouseX and Y be a variables? if so how?
@thebeatsync4328
@thebeatsync4328 Жыл бұрын
how to make triangles in loop ?
@rezaarian237
@rezaarian237 6 жыл бұрын
dude, you are perfect
@revolvency
@revolvency Жыл бұрын
I think you need to explain the syntax here, I realized that it 'for' can only have 3 expression in it
@minigooshey
@minigooshey 8 жыл бұрын
Hey Dan, I've run into an issue that's really confusing me. Why is it that sometimes when I set a variable before the setup function it works, and other times it does not? The p5 FAQ answers a question similar to it, and basically says that you can declare a variable before setup, but you must initialize the value inside setup for it to be used. Problem is even if I DO declare it before setup, then initialize it inside setup, it still doesn't affect anything inside draw. The exact same code works just fine if I set the variable inside draw.
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
I'd have to see the specific code to know why. can you post and ask at forum.processing.org?
@alexandermcclure6185
@alexandermcclure6185 9 ай бұрын
What about for each?
@joneshshrestha
@joneshshrestha 6 жыл бұрын
Love from Nepal. 🇳🇵
@9880808898
@9880808898 4 жыл бұрын
so good proffesor
@vrooomize
@vrooomize 5 жыл бұрын
Why in your script, background(0); in Draw() {} don't erase bubbles anytime?
@TheCodingTrain
@TheCodingTrain 5 жыл бұрын
It appears before I draw the bubbles so the bubbles appear on top. For more, ask at discourse.processing.org/! It's a better platform for Processing and p5.js related code questions. You can share code there easily! Feel free to link from here to your post.
@nimbus1583
@nimbus1583 7 жыл бұрын
In the beginning of the lesson I was very confused cause I thought that the draw function went on forever so why does the ellipses with the +1 x only go so many times
@nimbus1583
@nimbus1583 7 жыл бұрын
Nvm
@nimbus1583
@nimbus1583 7 жыл бұрын
Ow I have a new issue! In brackets my for loop never works!
@kennyl7542
@kennyl7542 9 жыл бұрын
Hi Dan, thanks for this great work. I have a more general question: do you know any resources of teaching/learning math using processing? (while I am doing processing exercises examples, I found myself understand basic math better as it is visualized through shapes, sizes, distances and movements. So, I wonder whether someone has tried to use processing and its style to teach or help students learn math through programming in processing?)
@kennyl7542
@kennyl7542 9 жыл бұрын
Absolutely, it is even better. Thanks
@gamebrain4222
@gamebrain4222 7 жыл бұрын
help! brackets is saying to move var declarations to the top of the function when i type for (var = x; x
@sdolby1
@sdolby1 7 жыл бұрын
for (var x = 0; x
@gamebrain4222
@gamebrain4222 7 жыл бұрын
Stephen Dolby I found out myself :/ stupid mistake thanks anyways!
@maximos118
@maximos118 6 жыл бұрын
Hi Daniel! Still slowly working my way through your videos. Really good stuff buddy. I'm learning so much from you! I have a question regarding while and for statements. I'm noting down everything I learn with categorisation and colour coding in order to potentially improve the amount of information I'm actually taking in. My colour coding method is one that I've predicted would be most useful in the future. Var's are Blue, Fun's are Green, Strings are Red and Boolean's are Purple. All with their subheadings or chapters that contain all the relevant information. My question is, under what category would I put while and for? These are simply statements that don't fall under the category of a variable type am I correct? Would it be best to simply make an entirely new category called Statements do you think? Thanks for all your help! Max.
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
I consider them "control structures" -- they control the flow of the program. And I would put them in the same category as if, else if, and else!
@maximos118
@maximos118 6 жыл бұрын
@@TheCodingTrain Thanks for your answer and support! With shorthand stuff like x = x + 50; x += 50; do you advise I start using those shorthand techniques already while I learn or wait until a later date? Also... I keep crashing p5 while creating while and for loops. Are there any techniques to avoid such mishaps?
4.2: Nested Loops - p5.js Tutorial
9:24
The Coding Train
Рет қаралды 168 М.
5.1: Function Basics - p5.js Tutorial
12:35
The Coding Train
Рет қаралды 149 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
Drawing Shapes in p5.js for Beginners (1.3)
25:47
The Coding Train
Рет қаралды 465 М.
JavaScript Loops Made Easy
10:52
codeSTACKr
Рет қаралды 176 М.
3.1: Introduction to Conditional Statements - p5.js Tutorial
11:31
The Coding Train
Рет қаралды 205 М.
3.4: Boolean Variables - p5.js Tutorial
19:39
The Coding Train
Рет қаралды 148 М.
Compilers, How They Work, And Writing Them From Scratch
23:53
Adam McDaniel (kiwi)
Рет қаралды 245 М.
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 578 М.
The Genius Way Computers Multiply Big Numbers
22:04
PurpleMind
Рет қаралды 310 М.
For Loops - Beau teaches JavaScript
6:37
freeCodeCamp.org
Рет қаралды 96 М.
Coding Challenge 171: Wave Function Collapse
1:18:37
The Coding Train
Рет қаралды 564 М.
"C" Programming Language: Brian Kernighan - Computerphile
8:26
Computerphile
Рет қаралды 1,9 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН