4.3: Using random() - Processing Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ก.ค. 2015
  • This video demonstrates the random() function in Processing in the context of assigning variable values.
    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...

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

  • @Sir_BoazMutatayi
    @Sir_BoazMutatayi 8 ปีที่แล้ว +150

    I would've never felt dumb if i had you as my professor. Thank you for making it very clear to me.

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

      +Sir. Boaz Mutatay thanks for the nice feedback!

    • @Dirt_Wizard
      @Dirt_Wizard 8 ปีที่แล้ว +3

      +Sir. Boaz Mutatay You're so goddamn right.

  • @giantswing3175
    @giantswing3175 6 ปีที่แล้ว +79

    Dude you really are an amazing teacher, my only advice and I'm sure many others will agree with me is that you seem to worry too much about video length and going a little bit off-topic, maybe there is an external reason for that (maybe if you use your videos in classes and you need them to be a specific length or whatever) but I dont care if the video could be "compressed" 1-3 minutes shorter, I watch your channel not only because your explanations are top-notch but because your personality and energy is super fun and entertaining, so having you talk about something not strictly related with the topic at hand for a brief moment is really enjoyable and serves like a brief pause from all the technical stuff.
    Anyway sorry for the 200 word essay, love your vids, keep up the good work!

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

      +giantSwing thank you I really appreciate the feedback!

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

    Just great!!! I never thought that such a complex topic as programming could be explained with so much enthusiasm and energy!!! My applause!!!

  • @AbdulRehman-yo2qn
    @AbdulRehman-yo2qn 8 ปีที่แล้ว +21

    You have a really unique style of teaching, and you explain every little thing that could be hard to comprehend by some people..which is really helpful.

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

      +Abdul Rehman Really appreciate the nice feedback!

  • @weltraumimport
    @weltraumimport 7 ปีที่แล้ว +38

    that was a perfect pen catch at 7:10 i'm impressed

  • @valkyrie-randgris
    @valkyrie-randgris 3 ปีที่แล้ว

    I love how happy and high energy this guy is. Honestly it's super fucking helpful. It's early, I'm confused, I'm tired, and I have a big project lying in front of me, but this guy is cheerful and excited by coding and it's contagious!

  • @aqualina-josephina
    @aqualina-josephina 4 ปีที่แล้ว +3

    I made a rainbow, out of randomly generated ellipses between size 10 and 50. With colors also in different shades of the main color. In pastel. I love it.

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

    The fact that programming/computer science teachers and professors are so much more laid back than others makes me enjoy this field even more.

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

      If I had to guess, it’s because they KNOW their field is a sought-after and respected one. Everyone needs a programmer working at their company. They do not have to convince you what they’re trying to teach you is valuable in some way, like many other professors get caught up doing.

  • @mauricioarroyo4112
    @mauricioarroyo4112 5 ปีที่แล้ว +12

    Best professor ever, thank you so much

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

    I have a test tomorrow and you have single handedly saved by bacon. I salute you, oh great coding sensei

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

    Your processing tutorials are amazing ! My professor is so monotone when he talks and he's not that clear when explaining concepts like this so thank you for saving my behind with these tutorials . Love the excitement it is really encouraging. Keep it up and I love the examples as well !

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

      Glad to hear, thanks for watching!

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

    you have amazing courses,thanks :) :)

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

    Thank you very much. My informatic teacher just sends us solutions and does not want to explain them to us.. baad.. but thank you soo soo much.. it´s was just so cool to watch your video and everything went after watching it. You´re the best! :)

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

    thank you for this tutorial! Very helpfull for my current project!

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

    Here is the code for colour circles with random positions
    It is vary cool
    Thanks Coding Train you are awesome and keep going with those awesome videos
    The code:
    float circleX;
    float circleY;
    float r;
    float g;
    float b;
    void setup()
    {
    size(640,360);
    circleX=width/2;
    circleY=height/2;
    background(50);
    }
    void draw()
    {
    r=random(0,255);
    g=random(0,255);
    b=random(0,255);
    circleX=random(0,width);
    circleY=random(0,height);
    fill(r,g,b);
    ellipse(circleX,circleY,24,24);
    //circleY=circleY-1;
    }

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

    I am your biggest fan! thank you for the videos, they help SO MUCH!!

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

      +Hannah Stevenon thanks so much, so glad to hear!

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

    okay wow honestly not complaining at all but how are your videos free??? This is saving my whole life

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

    Bonjour Daniel et un grand MERCI! Vos cours sont tout simplement formidables!!! :)

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

      LA FRAAAAAANCE

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

      what

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

    your videos do help btw; i am taking a comp sci class and have absolutely no idea what I'm doing but this helped a lot. I literally spent like 30 mins just trying out what was close to how you increased the size( i have to increase the size of a shape only if left mouse was used) i tried xSize++ in the shapes format and under the else statement.

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

    You made me laugh with your little walk from one screen to the other at 4:10 - these little strange and humorous things make your videos so relatable. Thank you 😊

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

      Pl

    • @Hasahn.
      @Hasahn. ปีที่แล้ว

      Haha yeah its like I'm watching Blue's Clues

  • @alina-rx3uv
    @alina-rx3uv ปีที่แล้ว

    i'm really struggling with programming at university so this really helped me a lot thank you so much, my code works now haha :)

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

    This guy is insane.
    I like him.

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

    okay, this random() function is pretty darn cool.

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

    thanks sir , i am learning and feeling it easy because of you.

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

    Thanks for the amazing videos! very didactic and funny :)

  • @AbhishekMishra-fr7po
    @AbhishekMishra-fr7po 3 ปีที่แล้ว

    Love your enthusiasm

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

    thank you so much! Very helpful for my work...

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

    you make me want to stay inside and code all day

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

    Hi, I just started the course, sorry if what i say it is not correct. I realise something by mistake, and i don't understand why it happens.
    if I declare a variable by using "float size;" and i initialise it using "size=random(20,70)"
    when i use it, it keeps the changes at the same rate for the width and height so the circle it's always a perfect circle of different size. If I instead use just the random function on the width and height of the ellipse it randomise the size of the object not equally by width and height so it shows different shaped ellipses.
    I'm really loving this course! This is a great channel!
    Thanks a lot!

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

    This is so inspiring. Thank you for all these tutorials, I love you

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

    thank you so much sir your videos help much

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

    my ocd wanted to see the circles paint out all the background before the video ended. darn you!

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

    Hello, thanks for your videos !
    How I do for slow down the distance traveled ?

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

    Thank you from 2021

  • @user-zk3bc6cc2g
    @user-zk3bc6cc2g 7 ปีที่แล้ว

    That's what makes me wanna apply to NYU

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

    Thank you for the tutorial. It was really helpful. I was just wondering how could you cap it to make only 5 random circles for example? Thanks.

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

      +Jasmin Harris If you look ahead to videos about loops and arrays this would allow you to more easily control the number of circles drawn.
      th-cam.com/play/PLRqwX-V7Uu6bm-3M4Wntd4yYZGKwiKfrQ.html
      th-cam.com/play/PLRqwX-V7Uu6bO9RKxHObluh-aPgrrvb4a.html

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

    Thanks man

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

    Him: *Talking about how if you heated up gas and watch the particles* at 5:44
    Me: I just wanna make a random number generate

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

    Nice to hear you are happy on the first second of this video. :)
    Why is it not possible to set the "size" function outside of the "setup" scope (befor the variable declaration) ? then you could use the "width/2" variable?
    i get follow error : "it looks like you're mixing "active" and "static" modes. (when i try this)

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

      Your code has to be inside a function for it to be executed. setup() is the function that starts at the beginning so it's the place for size()!

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

      In draw(), you have to use surface.setSize() instead of size()

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

    I have a question: I want the x value of a square to change randomly, but in increments of 50. I have random(0,width). but I only want to pick like 0, 50, 100, 150 and so on...

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

    Tid-bit:
    The operation `x = x + ___` is so common that there's a shorthand: `x += ___`! If you want to just increment by 1, like `x += 1`, you can even shorten that by just saying `x++`!

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

    6:10 Aah, i get it. Declaring circleX to be a float datatype means that when it runs 'random()' it will include numbers with decimals.
    So, 'random()' is is partially defined by the datatype it is drawing from and whether or not it is immediately inside of a statement that states a datatype .
    I saw that if you were to put 'random()' inside of 'int()' you would be able to limit it to integers even though the datatype was originally a float. My understanding is that that would be bad code though, or at-least a waste of memory since it would be less efficient than declaring it as an int in the beginning.
    This isn't so bad! I think I'm getting it. This is my first time learning how to program. I'm surprising myself, i didn't think i had it in me.
    (...and then i scroll down and see that youve already written that below in the comments.....*facepalm*)

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

      +Indigo Veilplume Yes, this is right! random() by definition returns a float (i.e. decimal) number but that can always be converted after the fact.

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

    I'd like to do the make the velocity of my ball a random number between -6 and 6 but without the 0, everytime the ball gets reseted. Any ideas how to accomplish that?

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

    4:47 In every language I have encountered before, including C64 Basic, Turbo Pascal 3, C/C++, Ada, PHP, Python, C# (shudder), and plain Java, the simple use of the random function would have been defined to work exactly this way, always generating the exact same sequence of pseudo random numbers--unless you seed it with a different number every time, from sources such as the system clock or the current mouse position. How do you control the random seed in Processing?

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

    you're so genius, i enjoy watching your videos!
    can you make coding " world clock" please?
    can someone help me?
    i'm so glad if you can

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

      Me too
      i really need coding of world clock too, please help me

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

    Hi, I'm a bit unsure of how to get the ellipse in a randomised y position. So for instance when I do randomise the y position, the ellipse goes into many different y positions but I only want it to randomise the y position once every time I run the code. Any suggestions on how to do this?

  • @rutajurciukonyte7398
    @rutajurciukonyte7398 4 หลายเดือนก่อน

    How do you add another circle (for example different color) that appears in different random places? Now I'm adding another circle with the same values but it overlaps the first circle.

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

    omg, width will not work bevore you did your size(x,x); ..... thanks you pointet out what i did wrong ....i was just so used to do all the variables at the top. lesson learnt

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

    thecodingtrain where did you learned all about processing?

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

    I always thought that if you take whatever algorithm for a random number, and added it together with a few others, averaged the numbers, do it twice, then take the average of both of those averages, that number would be quite random, no? You can't take averages of averages, it doesn't work out, so is this decent algorithm?

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

    Hej Daniel!
    First of all Thank You for making these awesome tutorials! It is GOLD!
    Keep it doing please! :)
    Second, I am trying to make the exercise You suggested in the end of the video, namely to color the circles differently if they are in a specific area of the image.
    I understand that I can use if statements, but the following code draws red circles also outside of the specified area.
    Could anybody enlighten me? Thank You in advance!
    float xpos;
    float ypos;
    void setup()
    {
    size(800,600);
    background(0,0,0);
    }
    void draw()
    {
    xpos = random(15,width-15);
    ypos = random(15,height-15);
    ellipse(xpos,ypos,30,30);
    if(xpos

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

      The problem is resolved!
      I should draw the ellipse after the if evaluation... ;)

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

    Was that thing on your shirt created using processing?

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

    This videos of yours are exactly as good today as they were in 2015. Thank you for sharing your knowledge in a clear and fun way. I really enjoy your videos.
    I have a little question, tho: If I type in the circles position on the x-axis as "random(-2, 2)" it will be sett to anything from -2 to 1.9999999 or something. And if Processing just cutting away the decimal points (this video on 6.50: th-cam.com/video/rZ36BzXFT6Q/w-d-xo.html), isn't it just possible for the circle to move from -2 (very little chance) to 1? Or is it really rounding up to nearest int?
    Keep up the good work!

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

      Yes if you use int() or floor() the decimal place is lost so you would just get -1, 0, or 1. Best way is to write some code and test and println() the results!

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

      @@TheCodingTrain Thank you for answering. Short and constructive. Love your work!

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

    Hi! I have a question. I'm trying to create a text whose fill changes randomly whenever I press a key. The thing is that I would like to generate a random color each time I press that key instead of once I've pressed it, for it to generate random colors all the time. I would like the random generated color to stay the way in was created until I press that key again. I'm going nuts about it and don't really know how to make that possible. Could you help me please? I hope I explained myself properly ;)

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

    I made a random circle generator like you did but with random color and length of the circle
    void setup() {
    size(600,600);
    background(50);
    }
    void draw() {
    float red = random(255);
    float green = random(255);
    float blue = random(255);
    float circleX = random(width);
    float circleY = random(height);
    float circLengh = random(10,100);
    stroke(0);
    fill(red,green,blue);
    ellipse(circleX,circleY,circLengh,circLengh);
    println("I just made a circle at " + circleX + ", " + circleY + " with a lenght of " + circLengh + "and at color of " + red + " " + green + " " + blue + " !");
    }

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

    I'm trying to make a game with the ball having random positions. I got it to do that, but it's moving fast as hell. How do i keep the speed controlled?

  • @youmah25
    @youmah25 8 ปีที่แล้ว +27

    i can't like the video twice

  • @jakes-dev1337
    @jakes-dev1337 2 ปีที่แล้ว

    Coding Train! Where can I get this patterned background?

  • @Tim-Jaeger
    @Tim-Jaeger 8 ปีที่แล้ว

    void setup() {
    size(640, 320);
    background(random(0, 255), random(0, 255), random(0, 255));
    }
    void draw() {
    fill(random(0, 255), random(0, 255), random(0, 255));
    stroke(random(0, 255), random(0, 255), random(0, 255));
    ellipse(random(0, width), random(0, height), random(0, 80), random(0, 80));
    }
    void mousePressed() {
    background(random(0, 255), random(0, 255), random(0, 255));
    }

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

    is there a way to get the random function to count by 2 or 3, etc, instead of by 1

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

      You can make an array that has the values you want to randomly choose.

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

    How do I put random color into the circles

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

    If I create an empty sketch and use the line print(random(100)), I get floats between 0 and 100, as expected. But then I have the same line code in the setup function of a different sketch (with many lines, functions, etc) and the random(100) function call doesn't seem to behave properly. I get floats ranging from 0 to much higher than 100, up into the thousands. Does anyone have an idea why this would happen?

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

      I figured it out. It turns out I was trying to print 2 different lines, which caused problems in the print output. The random() function was working fine. *noob*

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

    Thank uu so much!! Now I understand! Can you help me with something? I made this with stars (two triangles in a Pshape) and I want to program it so the stars won't touch each other, and the stars can only be at the top of the screen!

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

      I've managed to random the stars only in the top, but now I have to code something so that they won't touch each other!

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

      I would love to help! Can you ask this at forum.processing.org? It's easier for me and others to help that way (you can share code there easily!). Feel free to tweet me @shiffman a link so I can follow / contribute!

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

      Okay so I posted at the forum but I'm really new to this so I don't really understand what is happening there.. Could you try to explain it as simple as possible?
      forum.processing.org/two/discussion/21096/random-pshape-without-overlap

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

    what if I want to random 4 specific positions of an image?

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

      You can make an array that has the values you want to randomly choose.

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

    how would i create random color?
    i did hueX = random(255)
    but that just creates a random grey scale color halpp?

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

      GoofyMemes fill(random( 255), random(255), random(255));

  • @antares-the-one
    @antares-the-one 3 ปีที่แล้ว

    just imagine what is going on inside that head: writes code and refferes to the previously implemented variables; thinks about the good way of presenting information; speaks excelent language without flaws. And all of that at the same time. Now tell me! How to live in this world when there are peolple like him competing with you in this life?

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

    Can you fill a shape like for example a star with a lot of random images?

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

      +Caro Kaktus This is tricky to do, but definitely possible. texture() is a possibility or perhaps you could simply cover the image with rectangle with a star cut out of the middle. See beginContour().

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

      Thank you! I will try that.

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

      I had to do this for a assignment for school, made a star with two triangles in a Pshape!

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

    my circle is dragging it's colour all over the screen? any ideas?

    • @Delta.Steele
      @Delta.Steele 5 ปีที่แล้ว

      Maybe a bit late, but check where your background function is. If it’s in setup, then it will only draw it once, and your circle will appear to duplicate, or drag its color as you’re describing. You most likely want it in your draw function, so it draws over old circles. If that makes sense

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

    I started messing around with processing today, I tried to create a code that print the words true or false randomly, but im having some problems
    Heres the code
    float aleatorio;
    float random;
    void setup(){
    aleatorio = random(1,100);
    random = random(50,100);
    }
    void draw(){
    if(aleatorio > random){
    println("True");
    } else if(aleatorio < random){
    println("False");
    }
    }
    Im only getting True to be printed, if someone can explain why, id be happy

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

      Try printing out what values of the random number you're getting to see if your if statements are correctly written.

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

    Can i randomize with vertex? if so how do i do this? T_T

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

    how to get random whole numbers

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

    im trying to get a ball to spawn on one of three spots: 100, 200 and 300. i set the random to produce a number from 1 to 3 so that 1 is 100, 2 is 200 and 3 is 300, but somehow my random always produces 0. please help

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

      Would you mind asking 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.

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

      The Coding Train thanks, will do.

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

    I thought of 27 as well wtf?

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

    Hello, I actually can't find how to use the random function to have new random colors everytime my loop is reactivated in my program, could you help me please sir?

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

      random collors? int x=(int(random(255)); fill(x,x,x);

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

      João Miranda oh thank you, my professor actually explained me so i got my answer but thanks!

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

      thank you

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

    It's actually hard to listen to this at 2x speed.

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

    Daniel

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

    Although 27 is as random as 50. I don't like that you choose 27 LOL. That's just too "emotional random" for me

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

    Why do I already perfectly know how work the random() function and I'm still here ?

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

    19fps !?

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

    /**
    This programm generates an infinitely number of randomized
    circles on screen.
    **/
    /**
    Initiative variables
    **/
    float circleX; //x-position of circle
    float circleY; //y-position of circle
    int r, g, b, a = 0; //red, green, blue and alpha channel
    int size = 0; //size of circle
    /**
    Set-up screensize and background color.
    **/
    void setup() {
    size(800, 600);
    background(230);
    //position first ball on screen center
    circleX = width/2;
    circleY = height/2;
    }
    /**
    Draws a new randomized circle on any position on screen.
    **/
    void draw() {
    color c = color(a, r, g, b);
    fill(c); //fill the circle with a color
    ellipse(circleX, circleY, size, size);
    circleX = (int)random(0, width); //get a new random posiotion
    circleY = (int)random(0, height);//on screen
    size = (int)random(5, 70); //get a new random color for each
    a = (int)random(20, 80); //channel
    r = (int)random(0, 255);
    g = (int)random(0, 255);
    b = (int)random(0, 255);
    }

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

      What do you think, any suggestions or feedback?

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

      But the alpha would be the fourth argument in the color "function" wouldnt it? Like color(r,g,b,a) instead (a,r,g,b)

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

    how do i slow down random?

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

      by adding frameRate(100); to void setup. the framerate controls the random values generated per second, in this case 100.

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

      tried that, the goal was to make a snake-like game so it didn't really work. Already figured it out.

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

    u are amazing!!!!!!!!!!!!!!!!!!!!!!!
    Respect_||_

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

    Hello, if anyone wants to get free points, they can get them from Gamecrook.

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

    i want you to be my teacher

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

    Pretty good k lol

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

    ho

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

    baklol

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

    Hello, it seems that Gamecrook is only legit site for free gems, coins, gold or whatever.

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

    Bro have you ever been depressed in your entire life lmao