14 comments

  1. ahnaf nafi ahnaf nafi

    Great explanation

    first
  2. zerocool 18 zerocool 18

    thank you very much , nicely explained

    second
  3. mohamed saad mohamed saad

    Fantaaaaaaaaaaaaaastic

    third
  4. KOUSIK daniel KOUSIK daniel

    in first example you can pass two parameter in object but in method you have got only one argument….why? and number 50,100 are stored in memory but aP is how to replace 50 only

    4th
  5. Manuel A. Alonso Tarajano Manuel A. Alonso Tarajano

    so cool your explanations ! great job.

    5th
  6. Liam Attard Liam Attard

    I'm a beginner, but why does it change if there is void, doesn't void mean no return 🙁 ?

    6th
  7. Mulugeta Birhane Mulugeta Birhane

    well

    7th
  8. kevin benavides kevin benavides

    Thank you for clarifying this topic.

    8th
  9. Gamer Sparta Gamer Sparta

    It's the same in C++ ?

    9th
  10. Rick Cable Rick Cable

    Great video! Thanks

    10th
  11. Peter Bandsholm Peter Bandsholm

    Shiffman for president!!

    11th
  12. Lucas Bitar Piragine Lucas Bitar Piragine

    tried to add a particle but… (read more!)

    Heyy, Big Up from Brasil!!

    thanks for everything!!!

    I tried to add one more particle and the overlap function doesn't apply fully to the first particle called(p2) . I mean, when it overlaps one of the particles, the mouseParticle (p2) goes red, and the other goes green, but when the p2 overlaps the other circle(p3), it doesn't go red, only the overlapped goes green but (p2) keeps black.

    i figured it out that the order of the functions does matter, and the "problem" occurs on the first function declared.

    example:

    p2.overlaps(p1);
    p2 overlaps(p3);

    in this case, when p2 overlaps p1, p2 is still black and p1 goes green, and p2 goes red normally when overlaps p3…. and if I change the order

    p2.overlaps(p3);
    p2.overlaps(p1);

    then p2 only goes red when overlaps p1…

    i just don't understand why….

    mycode:

    Particle p1;
    Particle p2;
    Particle p3;

    void setup() {
    size(600,400);

    p1 = new Particle(100, 100, 50);
    p2 = new Particle ();
    p3 = new Particle(200, 200, 30);

    }

    void draw(){

    background(0);

    p2.overlaps(p3);
    p2.overlaps(p1);

    p2.x = mouseX;
    p2.y = mouseY;

    p1.display();
    p2.display();
    p3.display();

    }

    ///

    class Particle {

    float x, y;
    float r;
    color col;

    Particle() {
    x = random(width);
    y = random(height);
    r = random(20, 50);
    col = color(0, 100);
    }

    Particle(float tempX, float tempY, float tempR) {

    x = tempX;
    y = tempY;
    r = tempR;
    }

    void overlaps(Particle other) {
    float d = dist(x, y, other.x, other.y);
    if (d < r + other.r) {
    col = color(255, 0, 0, 100);
    other.col = color(0, 255, 0, 100);
    } else {
    col = color(0, 100);
    other.col = color (0, 100);
    }
    }

    void display() {
    stroke(255);
    fill(col);
    ellipse(x, y, r*2, r*2);
    }
    }

    12th
  13. Mohsan KAYANI Mohsan KAYANI

    you confused me ! duahh !! but hats off liked your concept and java thingi !! :] thanks man !

    13th
  14. Hadeel Alharthi Hadeel Alharthi

    What a great teacher 🙂

    14th

Leave a Reply