9.4: Arrays and Loops - Processing Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ก.ค. 2015
  • (Note this video was shot in Fall 2012.)
    Book: Learning Processing A Beginner's Guide to Programming, Images,Animation, and Interaction
    Chapter: 9
    Official book website: learningprocessing.com/
    Twitter: / shiffman
    This video covers how to iterate over the contents of an array using a loop.
    github.com/shiffman/LearningP...
    github.com/shiffman/LearningP...
    Help us caption & translate this video!
    amara.org/v/QbxC/
    📄 Code of Conduct: github.com/CodingTrain/Code-o...

ความคิดเห็น • 116

  • @jessesmits3629
    @jessesmits3629 7 ปีที่แล้ว +84

    I stood up and applauded

  • @MrNateStC
    @MrNateStC 4 ปีที่แล้ว +45

    The reason these videos are so good is how genuinely excited you are about this stuff!

  • @DavidDaybreakASMR
    @DavidDaybreakASMR 7 ปีที่แล้ว +73

    "This has nothing to do with arrays, but I can't stop!"
    This is why I watch your videos. 😂

  • @JackLaidlaw
    @JackLaidlaw 6 ปีที่แล้ว +60

    Daniel, which function did you write to make yourself invisible at the end!?

  • @meetnikhil719
    @meetnikhil719 5 ปีที่แล้ว +11

    You think you are mumbling, but that mumbling is an interesting fact to me and knowledge. Thank you for making the videos.

  • @kellywithay
    @kellywithay ปีที่แล้ว +4

    I am currently learning processing at the University of Oklahoma as part of the Master's of Art and Technology program. Your videos and book (it's our textbook) is INVALUABLE! Thank you for making this easier to understand.

    • @TheCodingTrain
      @TheCodingTrain  ปีที่แล้ว +1

      I'm so happy to hear this, thank you for the generous support!

  • @KennethHolmDahlin
    @KennethHolmDahlin 8 ปีที่แล้ว +21

    You make learning to code entertaining and fun. Thanks for being you Daniel!

  • @DancingKeanu
    @DancingKeanu 7 หลายเดือนก่อน +1

    Best teacher in the world, he makes it totally worth to watch this video.

  • @corykilpatrick1175
    @corykilpatrick1175 5 ปีที่แล้ว +3

    These videos give me a reason to learn Processing. They're fun and informative. I always laugh and learn something new every time.

  • @ankita-mishikar116
    @ankita-mishikar116 3 ปีที่แล้ว

    I am sorry, I don’t have to pretend to be excited or happy while watching your video. I am already happy and excited for every video.

  • @furrane
    @furrane 8 ปีที่แล้ว +12

    Very nice channel Daniel, for a beginner in Processing this is truly gold mine ! My only regret is I tried by myself finding the answers on google before going through all your tutorial. I would have saved a lot of troubles watching this first ^^
    This is a true shame you got so few viewers because you have this way of explaining with a nice touch of humor =)
    Btw I loved how everything felt apart hardware side at the end of the episode xD

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว

      +Furrane Glad to hear, thank you!

    • @reginamclean-thomas9115
      @reginamclean-thomas9115 6 ปีที่แล้ว +1

      I've been trying to write a code with an array and A loop..... What did I do... go to google... and what happened I FAILED

  • @codewithryan4646
    @codewithryan4646 6 ปีที่แล้ว +3

    Love your work dan! Best coding course I have ever done!

  • @TearThatRedFlagDown
    @TearThatRedFlagDown 4 ปีที่แล้ว +1

    You're a great teacher, I've struggled for the longest time to understand what an array is and how I use it to display objects from a class I've created and just within like 15 minutes you've managed to make me understand. (this vid + last vid)
    Hell, I understand the practical use of a for loop too now. (Before I didn't even really understand when or where to use one, I did kinda understand and use while loops though.)
    Thank you so much.

  • @corey333p
    @corey333p 7 ปีที่แล้ว +56

    I'm excited because I think he's about to create a ton of bubbles

  • @henriqueoliveira3872
    @henriqueoliveira3872 4 ปีที่แล้ว

    Thank you so very much, you just by teaching the way you have contributed to humankind, and saved me from utter frustration. So it is with deep seriousness that I thank and congratulate you. Cheers!

  • @DancingKeanu
    @DancingKeanu 7 หลายเดือนก่อน

    Bro got me excited to see 1000 bubbles and actually smiled when I saw it, I was so happy😁

  • @bldubl
    @bldubl 4 ปีที่แล้ว

    Thanks, been struggling with how to comprehend arrays and this helped a lot

  • @syedbaryalay5849
    @syedbaryalay5849 6 ปีที่แล้ว +1

    finally found what i was looking for the last whole month

  • @luisalonsosandovalgomez1406
    @luisalonsosandovalgomez1406 7 ปีที่แล้ว +35

    flipped my desk at 7:00

    • @10produz90
      @10produz90 5 ปีที่แล้ว +3

      Luis Alonso Sandoval Gomez I flipped it at 11:24

    • @danthemancasey
      @danthemancasey 5 ปีที่แล้ว +1

      OH YEAH! I flipped my phone at 00:01!

  • @paulnelapati3890
    @paulnelapati3890 6 ปีที่แล้ว +2

    your the coolest teacher ever. swear.

  • @peacehuman3963
    @peacehuman3963 4 ปีที่แล้ว

    The way of teaching is simply awesome.
    Thanks brooooooooooo

  • @BATMAN10N
    @BATMAN10N 3 ปีที่แล้ว +1

    " im excited " believe me!! * :)
    also this guy is a cure for depression too!!! what a sensei!!

  • @EugeneAyindolmah
    @EugeneAyindolmah 4 ปีที่แล้ว +1

    Thanks for the p2d and p3d knowledge! I never knew about these before

  • @huizylove
    @huizylove ปีที่แล้ว

    Wow, you explain it wonderfully

  • @Chomu0
    @Chomu0 3 ปีที่แล้ว

    He even disappeared at the end. True code magician.

  • @stannisbarracuda5693
    @stannisbarracuda5693 6 ปีที่แล้ว +15

    WHY CANT YOU BE MY TEACHER , EVEN BETTER MY OLDER BROTHER

  • @purplemockingjayeyes
    @purplemockingjayeyes 7 ปีที่แล้ว

    this is so helpful! thank you so much

  • @zenoraalexander8583
    @zenoraalexander8583 4 ปีที่แล้ว +1

    You are incredible sire

  • @SadiaKhan-yi8eh
    @SadiaKhan-yi8eh 6 ปีที่แล้ว

    Great video just a quick question can we use for count loop? I hope
    you're familiar with it

  • @conando025
    @conando025 4 ปีที่แล้ว +2

    "edit the last minute out" seems like that never happened, but I'm not disappointed.

  • @JustAddWat3r
    @JustAddWat3r 5 ปีที่แล้ว +1

    got a 100 in my class because of this mans

  • @szilviemailje
    @szilviemailje 3 ปีที่แล้ว

    Awesome, I love you!

  • @sadlereh
    @sadlereh ปีที่แล้ว

    bro is crazy and its brilliant

  • @xpsyprod3808
    @xpsyprod3808 2 ปีที่แล้ว

    you just saved my exams:)

  • @henriqueoliveira3872
    @henriqueoliveira3872 4 ปีที่แล้ว

    Hey The Coding Train, how can I make this array bubble react when they collide? I can't find a way to distance an array bubble form another cause they are all [ i ]. Thanks love the channel.

  • @shrookwageh5976
    @shrookwageh5976 6 ปีที่แล้ว

    ur way is soooooooooooooo awesome

  • @seikochristopherward9908
    @seikochristopherward9908 2 ปีที่แล้ว

    Every Video starts: "We're close now we're close, trust me"

  • @rhys9408
    @rhys9408 7 ปีที่แล้ว

    How do your glasses effect the greenscreen image ????

  • @jaskiratsingh8562
    @jaskiratsingh8562 3 ปีที่แล้ว

    I came here to Clear my doubts about arrays but stayed here untill he gets 1000 bubbles🙂👏

  • @harutjun3950
    @harutjun3950 2 ปีที่แล้ว

    quick question. Is there a way to choose between two 2d arrays? For example:
    If( button 12 cards is clicked )
    use the array 1;
    if (button 14 cards is clicked)
    use array 2;

  • @Thermacon
    @Thermacon 7 ปีที่แล้ว

    This was in Processing 1... Holy crap Daniel :)

    • @TheCodingTrain
      @TheCodingTrain  7 ปีที่แล้ว

      Some of these videos are quite old!

  • @GregoMartocci
    @GregoMartocci 7 ปีที่แล้ว +9

    Dan how did you become invisible? lol! 11:26. Regards from Argentina!.

  • @FreedomStateFSS
    @FreedomStateFSS 3 ปีที่แล้ว

    How do you initialize a variable to have a different value depending on what class array its in (meaning class[0], class[1], class[2])

  • @leonelmendoza7146
    @leonelmendoza7146 4 ปีที่แล้ว

    Hi sir would you please upload a video about how to use clamps pleaseeeee

  • @animationseries117
    @animationseries117 4 ปีที่แล้ว

    Can you make a programm in which four consecutive rectangle of 90*90 move together and stop when key pressed. Size (360,360)
    No of the triangle should be decreased as it move further.

  • @nickyli8903
    @nickyli8903 4 ปีที่แล้ว

    does anyone know what video it is where he creates the function bubbles?

  • @banli8262
    @banli8262 7 ปีที่แล้ว +1

    Hi Dan, Thank you for making these tutorials, just want to ask you, how can I fill each one of the bubbles with different color? I tried to add fill under display function, but the result is all the bubbles flash with different colors again and again.

    • @prithvimadugula1993
      @prithvimadugula1993 7 ปีที่แล้ว

      Try This .
      Tab1
      Bubble[] bubbles = new Bubble[1000];
      void setup(){
      size(640,360);
      for(int i=0; i

    • @banli8262
      @banli8262 7 ปีที่แล้ว

      Thanks Prithvi! This is great! Can I ask you questions again if I have any problem in the future?

    • @prithvimadugula1993
      @prithvimadugula1993 5 ปีที่แล้ว

      @@banli8262 Sure!!

    • @cookiesdiary1511
      @cookiesdiary1511 2 ปีที่แล้ว

      @@prithvimadugula1993 i cant seem to find ur reply do you mind sending it again?

  • @E-nfileexe
    @E-nfileexe 5 ปีที่แล้ว

    Im a very late watcher to your videos and i would like to know which video you made to make the code for the Bubble tab at 5:41.
    Also your very (how do i say) Like my ADHD, very energetic and at times random (^ - ^). I really like it.

  • @okeabiodune
    @okeabiodune 21 วันที่ผ่านมา

    that is good!

  • @teveli3395
    @teveli3395 7 ปีที่แล้ว +1

    i made my code like you did but all bubbles moves in same place ????

  • @soadsam
    @soadsam 7 ปีที่แล้ว

    hi daniel so im having a problem working with arrays so far, im trying to combine object arrays with a bouncing ball object, im trying to make it to where when the balls collide they change directions and each get a separate fill color. ive gotten everything working so far, but when they collide for some reason only one changes color no matter how i change my code. any suggestions or would it help if i could post my code somewhere?

    • @TheCodingTrain
      @TheCodingTrain  7 ปีที่แล้ว

      I would suggest posting your code at forum.processing.org, thanks!

    • @TheCodingTrain
      @TheCodingTrain  7 ปีที่แล้ว

      try posting code at forum.processing.org

  • @PhaBeatz
    @PhaBeatz 8 ปีที่แล้ว

    awesome channel! :) but how do you make the bubbles keep on comin? for example i got an array with 10. they are comin but only once ?!

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว

      +AVNU you'll probably want to use an ArrayList. th-cam.com/video/HnSJZ4qTcwY/w-d-xo.html

    • @soonkpaik2037
      @soonkpaik2037 6 ปีที่แล้ว

      I really tried to catch up the following link. But it was extremely difficult. I really don't get the link..
      Can I ask you what I didn't get from that?

  • @PreKGraduate
    @PreKGraduate 6 ปีที่แล้ว

    Great video, but when I included the P2D parameter in the size function, it actually slowed down drastically! Just wondering if I'm the only person who experienced that?

  • @cowboylerma
    @cowboylerma 7 ปีที่แล้ว

    how'd I make it so that the bubbles would not overlap each other?

  • @GalinetteStudio
    @GalinetteStudio 6 ปีที่แล้ว

    I'm excited too to create a ton of bubbles...

  • @NehaSingh-nn1dy
    @NehaSingh-nn1dy 8 ปีที่แล้ว

    hey.. Have you done any videos on Recursions? curios to know.

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว

      +Neha Singh Take a look at these! th-cam.com/play/PLRqwX-V7Uu6bXUJvjnMWGU5SmjhI-OXef.html

  • @michaellieberman114
    @michaellieberman114 5 ปีที่แล้ว

    If I apply random values to xspeed and yspeed then theres no wall collision detection in that direction. If I apply random to xspeed then I have a bunch of balls bouncing up and down and vibrating randomly side to side but they leave the screen eventually to the sides. Having less than 30 makes it obvious that they r leaving x=0 And x=width. Why does random do tht how can I prevent this?

  • @jacobc6260
    @jacobc6260 3 ปีที่แล้ว

    Please how did you make the bubbles reset and start at the bottem

  • @uhcougarfierce
    @uhcougarfierce 2 ปีที่แล้ว

    Thanks!

  • @ganeshparmar303
    @ganeshparmar303 6 ปีที่แล้ว

    which editor do you use to make programs..
    plz tell

  • @ankita-mishikar116
    @ankita-mishikar116 3 ปีที่แล้ว +1

    bubbles[i] = new Bubble(64) ;
    shows me an error that the class Bubble isn’t defined

  • @saatfj
    @saatfj 2 ปีที่แล้ว

    Daniel, The Code for the Bubble class(2nd tab) is not available, please upload the code, I look in previous videos but it is different. Thanks.

  • @christophermaduka4815
    @christophermaduka4815 ปีที่แล้ว

    I don't get how u got two different x values with the constructor argument. the other tab is not open?

  • @corrompido7680
    @corrompido7680 7 ปีที่แล้ว +9

    I love how you pooped like a bubble in the minute 11:25

    • @jochemcasier6974
      @jochemcasier6974 3 ปีที่แล้ว

      Never seen bubbles poop

    • @guys_animations
      @guys_animations 3 ปีที่แล้ว +1

      never seen bubbles p- oh, someone else said it already

  • @parhaikaam40
    @parhaikaam40 4 ปีที่แล้ว

    which software you are using for coding, sorry i didnt watch your first videos

  • @koenterheegde9328
    @koenterheegde9328 3 ปีที่แล้ว

    I constantly get a NullPointerException and can't solve it. Does anyone know how? I used the same code as in the video.

  • @MAXYANKEE5
    @MAXYANKEE5 7 ปีที่แล้ว

    PLEASE HELP!!!
    How are you getting them to continuously appear, I have an array list that results in multiple objects to fall down the screen, but when they leave the screen more don't come. How do i get another wave to come?

    • @HectorialInfection
      @HectorialInfection 6 ปีที่แล้ว +2

      I hope this helps. It's the code for the Bubble class I made for this example. They go up instead of down like in the video, but if you look at the "top" function I have, hopefully it will help you get an idea of what you could do.
      class Bubble {
      float x, y; // position
      float yV; // speed of bubble
      float r; // radius of bubble (diameter / 2)
      Bubble(float tempR) {
      r = tempR;
      x = random(r, width-r);
      y = height-r;
      yV = -1 * random(0.25, 4);
      }
      void display() {
      stroke(0);
      fill(127, 63);
      ellipse(x, y, 2*r, 2*r);
      }
      void ascend() {
      x = x + random(-3, 3);
      y = y + yV;
      }
      // Here's the "top" function:
      void top() {
      if (y

    • @cookiesdiary1511
      @cookiesdiary1511 2 ปีที่แล้ว

      @@HectorialInfection why does it say that width cannot be resolved to a variable?

  • @AkaiRyu
    @AkaiRyu 6 ปีที่แล้ว +3

    I see bubbles everywhere in my mind.

  • @migas4friends247
    @migas4friends247 4 ปีที่แล้ว

    You didn´t show the entire class Bubble in the video

  • @guys_animations
    @guys_animations 3 ปีที่แล้ว

    NullPointerException?

  • @gabrielus123gabby
    @gabrielus123gabby 6 ปีที่แล้ว

    0:49 you always do xD

  • @luisvasquez4932
    @luisvasquez4932 8 ปีที่แล้ว

    what if you want to push away the balls through mouse clicks? Thanks!

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว +1

      +Luis Vasquez You can use a "repulsion" force. I cover this concept in my Nature of Code video series: th-cam.com/play/PLRqwX-V7Uu6ZRrqLcQ5BkBKmBLiGD8n4O.html

    • @luisvasquez4932
      @luisvasquez4932 8 ปีที่แล้ว

      How do I open the lid of a box through a mouse click, counterclockwise and 180 degrees?

    • @luisvasquez4932
      @luisvasquez4932 8 ปีที่แล้ว

      and by mouse clicks i mean a button on the side. That button opens the box and changes the color of the box. Once it is clicked again, the box closes

    • @luisvasquez4932
      @luisvasquez4932 8 ปีที่แล้ว

      like this
      dl.dropboxusercontent.com/u/4181195/HatchDemo.mp4

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว +1

      +Luis Vasquez There are a lot of pieces involved in a problem like this. You can look at conditional statements and boolean variables for the button, you'll need to investigate translate() and rotate() for the box. I might suggest starting a thread at forum.processing.org for further discussion.

  • @dassad9777
    @dassad9777 ปีที่แล้ว

    5:18 you should change 2nd loop not to 20 but to length od array
    Edit: OOPS i just noticed you did it. 🤣

  • @FlySilky
    @FlySilky 5 ปีที่แล้ว

    BUBBLES!

  • @texasfossilguy
    @texasfossilguy 2 ปีที่แล้ว

    Now do it in 3D and make them coalesce 😅

  • @afrobear2310
    @afrobear2310 3 ปีที่แล้ว

    1000 bubbles = foam

  • @ryanharris4066
    @ryanharris4066 4 ปีที่แล้ว

    Jajaja, you disappeared!

  • @moritzsommer50
    @moritzsommer50 2 ปีที่แล้ว +1

    Klaus klaus klaus

  • @Romanychev_Iliy_G7
    @Romanychev_Iliy_G7 3 ปีที่แล้ว +1

    P3D ;-) !!!!!!

  • @Romanychev_Iliy_G7
    @Romanychev_Iliy_G7 3 ปีที่แล้ว +1

    P2D ;) !!!!

  • @leechaktatotato3355
    @leechaktatotato3355 5 ปีที่แล้ว

    I stood up and applauded