9.5: Arrays of Flexible Size - Processing Tutorial

Поделиться
HTML-код
  • Опубликовано: 9 фев 2025
  • Book: Learning Processing A Beginner's Guide to Programming, Images, Animation, and Interaction
    Chapter: 9
    Official book website: learningprocess...
    Twitter: / shiffman
    This video discusses the inevitable quandary of what to do when you want to resize your array dynamically while a program is running.
    github.com/shi...
    For ArrayLists, check out this video:
    • 4.2: ArrayLists in Pro...
    Help us caption & translate this video!
    amara.org/v/QbxB/
    📄 Code of Conduct: github.com/Cod...

Комментарии • 79

  • @VoyivodaFTW1
    @VoyivodaFTW1 7 лет назад +70

    your tutorials are just perfect

  • @SuperBoinger
    @SuperBoinger 9 лет назад +25

    Really great videos! I got into programming last year. Decided to teach myself, and after trying few tutorials (python/JAVA/Khan academy ) finally found Processing! it has so far has been the most productive and effective way for me to learn. Thank you very much Daniel Shiffman! (and processing team!)

    • @TheCodingTrain
      @TheCodingTrain  9 лет назад +1

      +apxnmed21322314 so glad to hear, thank you!

  • @charliethunkman
    @charliethunkman Год назад

    Watching in 2023 --- This Daniel guy has really gotten more professional in making videos, but the content is more reliable than the chat AI that was recently released.

  • @ahmadalghooneh2105
    @ahmadalghooneh2105 4 года назад +5

    Is there anyone who couldn't love this guy ?!

  • @abdullahalsubihi4266
    @abdullahalsubihi4266 7 лет назад +1

    Dan I'm a Telecommunications engineer and 3 weeks ago I had ZERO knowledge abou coding and programming.
    I have enjoyed every second of your videos and I have learned so much in programming that I have ever imagined.
    Today I have finished this video and proudly I have made a game with OOP and arrays.
    I really want to meet you in person and give a real gift for what you have taught me because just saying thank you in the comments isn't enough.

    • @abdullahalsubihi4266
      @abdullahalsubihi4266 7 лет назад

      Also I want to show you my game. I know you wouldn't like it because there is no comments on them but I will comment on it if you agreed to see my code. I talked too much already 😂. Than you and you are awesome 👍❤️

    • @TheCodingTrain
      @TheCodingTrain  7 лет назад +1

      This is so amazing to hear thank you for the nice feedback!

    • @victornecromancer
      @victornecromancer 6 лет назад

      Hello, did you build the game in Processing? Or another engine?

  • @ozzyfromspace
    @ozzyfromspace 6 лет назад +6

    You make a lot of sense, and I appreciate your effort! You do sometimes ramble though

    • @woulg
      @woulg 3 года назад +1

      It's part of the magic hahah

  • @paladin1147
    @paladin1147 6 лет назад +1

    YOU ARE AMAZING, Okay!!! Your deeds will not go unnoticed young sir!

  • @nanweicai6366
    @nanweicai6366 6 лет назад +2

    best tutorials ever seen

  • @arturkarlov3000
    @arturkarlov3000 9 лет назад

    ok, now I know that I can happily go to videos for chapter 15. oh well. hopefully chapters 10-14 videos will see the light of day some day.

  • @william-wijaya
    @william-wijaya 5 лет назад +43

    Thanks for the tutorial, I made a little game out of it.
    ArrayList bs = new ArrayList();
    int time;
    //0 = intro
    //1 = start
    //2 = end
    int state;
    void setup() {
    size(640, 360);
    state = 0;
    }
    void draw() {
    switch(state) {
    case 0:
    background(0);
    fill(255);
    textAlign(CENTER);
    textSize(32);
    text("BUBBLE CLICKER", width/2, height/2);
    textSize(16);
    text("Mouse(LEFT) to pop", width/2, height/2 + 20);
    text("Mouse(MIDDLE) to reset", width/2, height/2 + 40);
    text("Mouse(RIGHT) to add bubble", width/2, height/2 + 60);
    text("CLICK TO START", width/2, height/2 + 100);
    break;
    case 1:
    background(0);
    fill(255);
    textAlign(LEFT);
    textSize(24);
    text("Bubble= "+bs.size(), 10, 24);
    textAlign(RIGHT);
    textSize(16);
    text("F= "+floor(frameRate), width-10, 16);
    break;
    case 2:
    background(0);
    fill(255);
    textAlign(CENTER);
    textSize(24);
    text("YOU WIN", width/2, height/2);
    break;
    }
    //for (Bubble b : bs) {
    // b.display();
    // b.ascend();
    // b.top();
    //}
    if (state != 2) {
    for (int i = bs.size() - 1; i >= 0; i--) {
    bs.get(i).display();
    bs.get(i).ascend();
    bs.get(i).top();
    if (bs.get(i).popped() == true) {
    bs.remove(i);
    }
    }
    spawnEvery(2, 1);
    }

    if (state == 1 && bs.size()

    • @fjaramillo887
      @fjaramillo887 4 года назад

      I tried your game its pretty cool, congrats.

    • @samc1856
      @samc1856 4 года назад

      The first page is unresponsive for me, if I click, nothing happens. Maybe because I'm on a Mac? I'd love to play this!

    • @vinijoncrafts2882
      @vinijoncrafts2882 4 года назад +1

      Well, if you just press and hold the left button its not actually clicker but why i am complaning, im not able to do nor 1% of this! Great job!

    • @FreakishSmilePA
      @FreakishSmilePA Год назад

      lol four years later this is still really cool. It still works with the newer version of Processing.

  • @nasuhaahmad2122
    @nasuhaahmad2122 4 года назад

    although i couldnt solve my problem with this video yet i gain knowledge and it was very well explained sir . goodjod !

  • @dirtbuilder4615
    @dirtbuilder4615 5 лет назад

    I'm learning java sas and m so happy to find he video I realy needed a way to get all my objects into one array to build a decent collision system that is expendable

  • @Missi0n141
    @Missi0n141 9 лет назад +9

    Really useful, thank you +Daniel Shiffman

  • @yeehyun218
    @yeehyun218 9 лет назад +5

    Thank you so much for your brilliant lessons!

  • @BATMAN10N
    @BATMAN10N 4 года назад +1

    im so glad we both love bubbles!!!! :D

  • @SameBasicRiff
    @SameBasicRiff 6 лет назад +1

    omg ive been trying to get a mouse click to have a bubble appear since the object oriented tutorials that introduced bubbles. I literally just got it figured out as you say it in this video (im watching and following along while trying the code on my laptop).
    Interested now to see the end of this video and how its done different/ similar. Right now i have a maxBubbles variables initializing the array and a bubblesDisplayed variable for "i" in my draw function for loop. every mouse click increments "bubblesDisplayed" but maxBubbles is static. Very cool!
    edit* annnnnnd thats the exact same way this video shows! awesome! you rock!

  • @Jalecko
    @Jalecko 5 лет назад

    Thank you so much for explaining this to me and linking me to that excelent example

  • @IIINatorIII
    @IIINatorIII 2 года назад

    Video still helps me thx

  • @dio8440
    @dio8440 4 года назад

    Thanks you sir! very nice tutorial!!!

  • @rituchandra6325
    @rituchandra6325 6 лет назад +1

    hey! i need some help with a code problem im having and i cannot understand whats causing i tor how to fix it... heres the problem:
    i wrote a program using arrays and objects to create ball objects on the screen wherever the mouse is clicked. now i wanted to make them bounce around on collision instead of just passing right through each other so i wrote a function called collide in which if the distance between the centres of the 2 balls was less than the sum of the radii then it would change their velocities! now i run the program and its running fine till there are about 5 balls on the screen but as soon as i get a high number of balls on the screen the balls *randomly* start overalpping with each other and start revolving around each other quirkily... i do not understand whats happening please help.

  • @CamilaHernandez-um6on
    @CamilaHernandez-um6on 8 лет назад

    this is magic, thank you!

  • @OxygenBeats
    @OxygenBeats 2 года назад

    7:16 sounds cool at x2 speed

  • @dhruvsharma2571
    @dhruvsharma2571 4 года назад

    Hey Daniel! Following on your tutorial, I created an animation of bubbles of random sizes moving upwards on the screen. I want to add a feature of the bubbles popping when they collide with each other. But it doesn't seem to work. I can't seem to figure out what code to write to make it work like I want. Could you please help with this problem?
    Bubble [] bubbles = new Bubble [100] ;
    void setup () {
    size (640, 480, P2D);
    for (int indices = 0; indices < bubbles.length; indices += 1) {
    bubbles [indices] = new Bubble (random (width), height, random (80));
    }
    }
    void draw () {
    background (0);
    for (int indices = 0; indices < bubbles.length; indices += 1) {
    bubbles[indices].ascend ();
    if (bubbles [indices].together (bubbles [indices])) {
    bubbles[indices].pops ();
    }
    bubbles[indices].display ();
    bubbles[indices].top ();
    }
    }
    class Bubble {
    float x, y;
    float d;
    float driftX;
    float speedY;
    float alpha;
    Bubble (float tempX, float tempY, float tempD) {
    x = tempX;
    y = tempY;
    d = tempD;
    driftX = 2;
    speedY = random (0.25, 2);
    alpha = random (20, 107);
    }
    void display () {
    fill (255, 223 + (random (-20, 0)), 0, alpha);
    noStroke ();
    ellipse (x, y, d, d);
    }
    void ascend () {
    x += random (driftX*-1, driftX);
    y -= speedY;
    }
    void top () {
    if (y+d < 0) {
    y = height;
    }
    }
    boolean together (Bubble other) {
    float distance = dist((x + d/2), (y+d/2), (other.x+((other.d)/2)), (other.y+((other.d)/2)));
    if (distance == 0) {
    return true;
    } else {
    return false;
    }
    }
    void pops () {
    d = 0;
    }
    }

  • @kiryl_dorakh
    @kiryl_dorakh 5 лет назад

    thanks for your videos!

  • @lee_sung_studio
    @lee_sung_studio 2 года назад +1

    4:53

  • @meganfrentzel8598
    @meganfrentzel8598 6 лет назад

    Is there any tutorials for using an array with millis()? I would like to add a bubble every second but also be able to click them away? is this possible?

  • @LfunkeyA
    @LfunkeyA 5 лет назад

    i don't get the part about a chance of a bubble appearing per frame. are we supposed to use some sort of frame function?

  • @simontewolde3616
    @simontewolde3616 9 лет назад

    I can't find chapter 10 for some reason. Did you even make one? It just goes straight to chapter 15 after this.

  • @jheelikna1540
    @jheelikna1540 8 лет назад

    can I draw random circles as you showed without using objects ?

  • @niedrumm6642
    @niedrumm6642 5 лет назад +1

    your tutorials are great but I wonder if it's possible to upload a game to steam with Processing. If it's possible can you make a tutorial, thanks :)

  • @baphnie
    @baphnie 4 года назад

    The github link is dead; where did he use his 'total' variable?

  • @vanessaangelica2957
    @vanessaangelica2957 6 лет назад

    do you think you can give us the code you used for this tutorial? also I am stuck on the exercises if anyone can help I would appreciate it so much!!

    • @TheCodingTrain
      @TheCodingTrain  6 лет назад +1

      I need to do a better job of organizing all the code. You can find it here: github.com/CodingTrain/website/tree/master/Tutorials/Processing/unsorted

    • @vanessaangelica2957
      @vanessaangelica2957 6 лет назад

      The Coding Train thank you so much!!!

  • @BoltCuddlefur
    @BoltCuddlefur 5 лет назад +1

    Good tutorial but pls push the Framerate at least up to 24 ;)
    I only see you stutter arround the picture.

  • @abhishekmodanval9768
    @abhishekmodanval9768 4 года назад

    Sir!!
    Can we declare an array as arr [2+3]
    Sir please comment 🙏

  • @cmdrnop4038
    @cmdrnop4038 4 года назад

    I'd love to see an array being created and read from a local buffer in a visual manner.
    If I create a pointer to this memory at x position. Then place a value at x + offset of data length. And use that to read and write from the buffer at an index. This would be the proper technique correct?
    It just seems so simple and visual this way.

  • @akshaynile2778
    @akshaynile2778 6 лет назад

    What if I keep pressing mouse button and reach 100 ?
    It will eventually throw OutofBounds exception.

  • @corykilpatrick1175
    @corykilpatrick1175 6 лет назад

    I don't get how the bubbles are continuing once they hit the top. There's nothing in your code that I see doing that! Help!

    • @Valoammus
      @Valoammus 6 лет назад +1

      Here's the bit of code inside the Bubble class, that makes the bubbles continue once they hit the top:
      void top(){
      if (y < -diameter/2){
      y = height+diameter/2;
      }
      }

  • @keanu_de_vos
    @keanu_de_vos Год назад

    Bro said he had a cough🤣right after having a cough😭

  • @myles199
    @myles199 8 лет назад +1

    Do you have any vids on 2d arrays??

    • @TheCodingTrain
      @TheCodingTrain  8 лет назад +6

      +Myles Jeremiah I believe I talk a bit about 2d arrays in this video: ruclips.net/video/tENSCEO-LEc/видео.html But yes, this seems like a missing topic! Will add to my list!

    • @dominichumphrey7060
      @dominichumphrey7060 8 лет назад +1

      Another request for that! Great tutorials thank you so much for making them

  • @nomadoflight
    @nomadoflight 8 лет назад

    Hi Dan, please make videos from the lesson 10 to 14. We are stuck here. It is important.
    Thanks in advance.

    • @TheCodingTrain
      @TheCodingTrain  8 лет назад

      +BABLU KUMAR I will try to get to this, but I have a bunch of things on my list first! For chapter 13 take a look at the nature of code series: ruclips.net/user/shiffmanplaylists?shelf_id=6&view=50&sort=dd

  • @onlogn3667
    @onlogn3667 4 года назад

    Nice

  • @amiltonmanuelpensamento9832
    @amiltonmanuelpensamento9832 6 лет назад

    Which language is being used for this tutorial?
    Is it Java?

    • @TheCodingTrain
      @TheCodingTrain  6 лет назад

      This video uses Processing (which is built on top of the Java programming language). For more info, visit processing.org and also this video might help ruclips.net/video/AmlAiKsiy0o/видео.html.

  • @addisonburkett6855
    @addisonburkett6855 4 года назад

    This dude is cracked

  • @swacharahman5084
    @swacharahman5084 4 года назад

    Hey,you look like harry Porter 😅btw nice explanation

  •  8 лет назад +1

  • @ai_zj
    @ai_zj 5 лет назад +1

    7:17

  • @pmsol225solo2
    @pmsol225solo2 4 года назад

    YOU ARE JAMESBOND

  • @TyrOSRS
    @TyrOSRS 3 года назад

    I love this guy lmao

  • @abagnale335
    @abagnale335 7 лет назад

    An array is a constant.

  • @andrewkiminhwan
    @andrewkiminhwan 9 лет назад

    flexible size, DOES matter :)

  • @DraxDestroyed12
    @DraxDestroyed12 3 года назад

    6:10 😂😂😂

  • @akshapalan5653
    @akshapalan5653 3 года назад

    please explain with programing language. come into the point.

  • @ritulsinghal1283
    @ritulsinghal1283 3 года назад

    for that never ending thing I just wrote this
    if (total>=100) {
    total=100/2;
    }
    can't think of anything else 😅😛
    And I don't understand the last exercise if anyone could explain......

  • @thehammerandsickle2490
    @thehammerandsickle2490 4 года назад

    I hate arraylists' syntax who thought it was a good idea to make their syntax look like that?

    • @Akniy
      @Akniy 3 года назад

      What's wrong with it? Pretty much almost every language has a similar syntax.