4.2: Incrementing a Variable - Processing Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ก.ค. 2015
  • This video demonstrates how to increment a variable's value after each cycle of the draw() function.
    Support this channel on Patreon: / codingtrain
    Contact: / shiffman
    Send me your questions and coding challenges!: github.com/CodingTrain/Rainbo...
    Link to code on Github: github.com/CodingTrain/Rainbo...
    Processing: processing.org
    Processing Foundation: processingfoundation.org/
    Learning Processing Book: learningprocessing.com/
    For More Processing Tutorials:
    th-cam.com/users/shiffman...
    📄 Code of Conduct: github.com/CodingTrain/Code-o...

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

  • @Yensnor
    @Yensnor 5 ปีที่แล้ว +117

    I tried for several years to get into programming. I knew the syntax, operators, functions, variables. I knew about them. Tried to use them. But i never could wrap my head around the concept of what programming truly is. At the most basic level. The logic behind it.
    After 12+ languages and hundred+ hours over many years, failing and giving up. I FINALLY found a teacher who could make me truly understand. From the intro to here, even though this is all pretty basic stuff, still. I've understood it, not 70%, not 95, but 100%, because you're an amazing teacher.
    You revealed the puzzle of programming for me. It's amazing to me that this is a free resource for anyone to absorb.
    A thousand thanks to you sir. You've made a random 26 y old norwegian dude, extremely happy.

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

      This sounds awesome. But there's one thing: why did you torture yourself so much when you didn't get the point of programming? Learning all these languages must've been hell, by all respect.

    • @ub-relax6800
      @ub-relax6800 6 หลายเดือนก่อน

      Pseudorandom

  • @koodig759
    @koodig759 8 ปีที่แล้ว +40

    Wow, this is so great, I am a Chinese and learning Processing by myself now. Wishing your book《LearningProcessing》can be translated in Chinese, but it is OK to me~I am so happy to improve my English and Processing both. HAHAHA, Thank you

  • @vjd7
    @vjd7 8 ปีที่แล้ว +32

    I've been trying to learn coding skills forever.. to no avail. Your high-energy videos are actually something I can understand and process (pun intended)! Thanks for making them available!

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

      +Jeremy Bessoff so glad to hear, thanks for the nice feedback!

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

    Thank you ! You literally saved me. I'm a graphic design student and we learnt Processing, i have an exam and I was so lost. Your explanations are clear and simple to understand !

  • @dancedonkey1
    @dancedonkey1 7 ปีที่แล้ว +18

    4:02 is my favourite part :'D
    thanks for being a teacher that gets excited over the most simple stuff :D! it makes me feel like even as a starter I'm accomplishing great things haha, thanks!!!

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

      dancedonkey1 agreed

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

      I knooow. I burst out laughing at that part. :d

  • @jennhott-leitsch7918
    @jennhott-leitsch7918 9 ปีที่แล้ว +20

    Thank you sir, for taking the time to make all of these videos. I am studying Processing this summer, and I have been so lost. Your videos have helped me so much! And I might actually pass my final now!!

  • @abevetrone1288
    @abevetrone1288 6 ปีที่แล้ว +5

    Hello, I will teach a "Creative Coding" class next year in high school and am very glad to have come across your videos. Helpful. And I am glad you did not have the time to edit out all the entertaining tangents and digressions!
    I can't remember which video you said it in but I agree, there are few activities more relaxing than throughly wiping off a white board.
    Thank you again. Keep GOING!

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

    Hands down best teacher I could find! I am blown away by your level of communication. I was watching things from harvard and other various places and none of them communicated these concepts with such a balance of theory and application. I am not only grasping these concepts but applying then and expanding on them and making them my own. You have my deepest appreciation

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

    i love it when he talks to himself :)
    makes me feel less intimidated by programming

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

    Loving the book and videos. Thanks so much for helping me dive into this new artistic horizon!

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

      +Sound8Vision so glad to hear, thanks for watching!

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

    Love your videos, you put so much energy in them :)

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

    Finally a teacher who teaches how my brain works

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

    great , we are moving on, keep going - thanks

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

    Also love the lessons they're very helpful! The energy helps so much, thank you so much! @TheCodingTrain

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

    dude i just love you so much, thanks.

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

    salam , Hi , you are the best , now i feel like i can be a programer , so funy plenty of info you making it so easy for us , I wish you were my teacher all this years . thanks man

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

    u make me love processing really ! i love u are energy i love u are aura! from cyprus xxx

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

    your videos are absolutely inspiring and when i first started watching i may have though " oh who tf is this human and his wild antics " but now i see the beauty in your humor and the nature of your persuasion towards becoming a more intellegent human being through humor and failure! /// DEF WORTH A SUBSCRIBE AND UPVOTE

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

    very entertaining! Great Job!!!!!!!!!!!!!!!!!!!!!

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

    Such a great video... really!!! Perfect explanation! I did not think so far that a half pixel doesn't exists......
    Here comes logical thinking....

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

    Hi Dan, the videos are excellent and I tried out speedX and speedY. It works great! By the way, I love your excitement for these videos
    float circleX = 0;
    float circleY = 0;
    float speedX = 1;
    float speedY = 1;
    float r = 24;
    void setup() {
    size(640, 360);
    }
    void draw() {
    background(0);
    fill(255);
    ellipse(circleX, circleY, r, r);
    circleX = circleX + speedX;
    circleY = circleY + speedY;
    }

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

    Hi, great tutorials, thanks! by the way, if we use the form circleX += 1 while the circleX type is still int we won't get an error but instead, the window will open up and the circle will simply not move.

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

    2021 just saw your explanation , thank you

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

    Love your videos! Question: When would we choose int over float, if float allows us to use integers and decimal numbers?

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

    So far I want to thank you so much as american are so decent and you are alike.

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

    For the ball to bounce between its x axis
    float posX;
    float posY;
    float speed;
    float dirX;
    void setup () {
    size (640, 640);
    posX = 320;
    posY = 320;
    speed = 5;
    dirX = 1;
    }
    void draw () {
    background (50);
    fill (255);
    hitWall ();
    posX += speed * dirX;
    ellipse (posX, posY, 60, 60);
    }
    void hitWall () {
    if (dirX == -1) {
    if (posX = 640) {
    dirX = -1;
    }
    }
    }

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

    HEYY!! i need help for a project! i need to make a fun code where i visualize sound!! any advice on where i can find tutorials of processing using beats?

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

    Do you have a video on drawing with trig? I am very confused by it.

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

    legend has it that the first ball is still moving

  • @bryananthony3924
    @bryananthony3924 3 หลายเดือนก่อน

    I don't really understand the animation logic from this code , I thought that if I want to animate something moving I would need some kind of time function to slow down the loop so we could see the different changes of the frame , but in here we don't use any time function so is the loop void draw () looping in a specific time interval ?

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

    hi, thanks for your videos! just a question. if the increment is frame per frame, does processing use a certain number of frames per second as default? and if so, which one?

    • @JurajPecháč
      @JurajPecháč 7 ปีที่แล้ว +1

      Alessandro Festuccia The default rate is 60 frames per second.

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

    What would the logic syntax be for the python version?

  • @tubattitobb
    @tubattitobb 10 หลายเดือนก่อน

    amo a este tipo dior

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

    How would I make that circle re-appear again from the spot it began (left) once it runs of the screen??
    Please help me!

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

      you need to make an if statement

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

    thanks(2019)

  • @dalenassar9152
    @dalenassar9152 7 ปีที่แล้ว +2

    So the circle will actually come back from the left after circlex=255 ? It still see's the "+1" increment.

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

      Just tell if it is equal to width

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

      It technically WILL come back after 2147XXXXXX frames (the XXX representing I don't remember the number) because it's a 32-bit value.

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

    How fast is the ellipse being drawn over and over when its static?

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

      James Gabbitus I don't know if I understand your question but i will answer what i think you said. Processing is running in 24 frames per second. It means that the circle is updating 24 times every second.

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

    Hey Daniel, I have a cuestion. Why if I print a value on the screen using C++ a statement like CircleX = CircleX + 1; just adds one unit to my preceeding value of CircleX meanwhile in P5.js seems like the instruction keeps executing indefinitely(because the ellipse keeps moving )?, for me the ellipse in your program should move just 1 unit to the right and then the program should stops or the ellipse should stops to move, but it´s not in that way, is there a difference in the way C++ process a scan with reference to P5.js, seems to me like P5.js keeps executing the program over and over and over again in a none sense way, I mean seems like P5.js Keep scaning indefinitely mean the creator wants. Please Help me, I want to Straddle in the Coding Train too. By the way your tutorials are the best, thanks to investing your time sharing your knowledge.😀

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

      This is related to how the draw() loop works in p5.js! th-cam.com/video/RnS0YNuLfQQ/w-d-xo.html

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

    THE COD
    int circleX;
    void setup () {
    size (640,640);
    circleX = 0;
    }
    void draw () {
    background (255);
    circleX = circleX + 1;
    fill (0);
    noStroke ();
    ellipse (circleX,50,25,25);}

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

    I'm thinking you can run a university course worldwide called processing

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

    With this i made a really stupid Flappy Bird game :D just the ball floating from the left to the right and down, and always when i press a key the ball jumps up a bit :D

  • @a17waysJackinn
    @a17waysJackinn 27 วันที่ผ่านมา

    omg if circlex created and in somethibg like 360hz display that might be fast as wild

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

    Is it possible to change the speed without changing the incremental value?
    Ie - Pausing the code, or making the code run twice as fast
    *If the only way to speed up the animation is to increment by 10 pixels, it would be impossible to quickly reach a point on the screen which is not a multiple of 10 pixels away

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

      You can change the frame rate (see processing.org/reference/frameRate_.html) but there's a limit to how fast a frame rate Processing can handle depending on a variety of factors.

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

      @@TheCodingTrain Cheers, thats exactly what I was after!

  • @awsomeguy563
    @awsomeguy563 7 ปีที่แล้ว +2

    it keeps on saying circlex cannot be resolved to a variable :((

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

      you need to use a float type of variable

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

    Dude, you're so funny

  • @lucaspop51
    @lucaspop51 5 ปีที่แล้ว +2

    In what language are you coding ?

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

      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 th-cam.com/video/AmlAiKsiy0o/w-d-xo.html.

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

    4:03 Daniel, can I hug you? :D

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

    Why Is this eerily similar to my JS classes on khan academy?? Is Java JS?!?!

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

    I don't know why this dude makes me laugh

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

    never mind, i figured it out....

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

    Daniel

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

    so how the hell do you make something to grow??? make it smaller or bigger???

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

      Variables! Thanks for watching!

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

    //How to draw rectangle like in paint. If smn know any easier variants pls tell
    float valueX = 0;
    float valueY = 0;
    void setup() {
    size(640, 360);
    }
    void draw() {
    background(102);
    fill(255,20,200);
    rectMode (CORNERS);
    if (mousePressed == true) {
    rect(valueX, valueY, mouseX, mouseY);;
    } else {
    rect(0, 0, 0, 0);
    }
    }
    void mousePressed () {
    valueX = mouseX;
    valueY = mouseY;
    }

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

    10:43 I'm dead HAHAH HI AGAIN

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

    It's saying variable circleX does not exist? I've copied yours

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

      Ah, the float.

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

    lol i used a for loop :)

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

    so this is very confusing to me with the equals sign being used to assign a value to something cause in Delphi we use := it's much more easier to understand. these videos are messing with my brain.

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

      You'll get used to it.

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

    pls write my CS exam for me that's tomorrow :(