[SOLVED] Having a visual problem with overlapping ellipses

For the speeding up, you just need to run what’s in your draw() function several time per frame.

So you just need to add a nbOfCycles variable and add a for loop in draw()

boolean XPlus = true, YPlus = true;
boolean RTrue = true, GTrue = false, BTrue = false;    
int once;
float SquareX, SquareY;
float Speed = 1;
float Size = 20;
float BackGround = 0;
float TraceX, TraceY;
int R = 0, G = 0, B = 0;
int nbOfCycles = 50;

void setup() {
  background(BackGround);
  noSmooth();
  fullScreen();
}  

void draw() {
  for (int i = 0; i < nbOfCycles; i++) {

    // Random Start Location //

    if (once == 0) {
      SquareX = random(0, width); 
      SquareY = random(0, height); 
      once++;
    }

    // Collision and Boundary Restriction Logic //  

    if (SquareX>=width-(Size/2)) {
      XPlus=false; 
      SquareX=width-(Size/2);
    }  

    if (SquareX<=0) {
      XPlus=true; 
      SquareX=0;
    }

    if (SquareY>=height-(Size/2)) {
      YPlus=false; 
      SquareY=height-(Size/2);
    }

    if (SquareY<=0) {
      YPlus=true; 
      SquareY=0;
    }

    // Collision Reaction Logic // 

    if (XPlus==false) {
      SquareX=SquareX-Speed;
    }

    if (XPlus==true) {
      SquareX=SquareX+Speed;
    }

    if (YPlus==false) {
      SquareY=SquareY-Speed;
    }

    if (YPlus==true) {
      SquareY=SquareY+Speed;
    } 

    // Trace Logic //

    if (XPlus==false) {
      TraceX=SquareX+Speed;
    }

    if (XPlus==true) {
      TraceX=SquareX-Speed;
    }

    if (YPlus==false) {
      TraceY=SquareY+Speed;
    }

    if (YPlus==true) {
      TraceY=SquareY-Speed;
    }

    // Color Logic //

    if (RTrue == true) {
      R++;
    }
    if (GTrue == true) {
      G++;
    }
    if (BTrue == true) {
      B++;
    }

    if (R >= 255) {
      RTrue = false; 
      GTrue = true;
    }
    if (G >= 255) {
      GTrue = false; 
      BTrue = true;
    }
    if (B >= 255) {
      BTrue = false; 
      RTrue = true;
    }

    if (RTrue == false && R > 0) {
      R--;
    }
    if (GTrue == false && G > 0) {
      G--;
    }
    if (BTrue == false && B > 0) {
      B--;
    }

    // Visuals //

    noStroke();
    fill(R, G, B);
    rect(TraceX, TraceY, Size, Size);
    noStroke();
    fill(255);
    rect(SquareX, SquareY, Size, Size);
  }
}

void mousePressed() {
  exit();
}

2 Likes