Circles appear each time the tool hits the player -beginner pls help

I am to trying to complete a project . It is like a game each time the tools come down the screen a circle should appear and fill the screen and if the tools hit the person in the game the circles turn to red.
I know that I have to use loops but I really do not know how to write a code that each time tools come down a circle appear on the screen and after filling goes to next row

There’s no need to starts so many different threads about the same sketch.

It’s very hard to help you because the description of what you want to accomplish translates almost directly into code. Consider:

if( tool.position.y > height ){ 
number_circles++;
if( collision_check() ){
circle_color = color(200,0,0);

The best advice is: DON’T DO EVERYTHING ALL AT ONCE.

Software development is a PROCESS. Start with something that you know works. Then change it very slightly. Does your slight change work? If so, great. If not, you know EXACTLY what you just changed - so it has to be the problem!

Do not try to make circles rain down all over the screen if the playe r collides with any tool and the score and the timer and the graphics and this and that and everything all at once. That is a nightmare!

Start with a circle. Can you draw a circle?

Don’t do anything else until you can do just one circle.

Now can you draw several of them to get the gradient that you like?

Don’t do anything else until the gradient works.

Now put that circle drawing code into a function. Does it still work?

Don’t do anything else until it does.

Now make sure you can control where that gradient circle is by passing position values to your function.

Make sure that works. Baby steps.

Now, how many gradient circles are you going to draw? Do you have a variable to track that?

Add a variable to track it.

Can you use just ONE loop to draw a ROW of them?

Once that works - and ONLY once that works - can you add a second loop to draw MANY rows of them?

Now can you number the circles?

Now can you add a condition to see if a circle should be drawn? (Hint: How many should be drawn? How are you recording that information?)

Add a collision check for one tool. test it. Does it work?

Add a loop to try the collision check for EVERY tool. test it.

See what I’m getting at here? Do things in steps. Small steps. Make sure one step works before you move on to the next.

1 Like

Thanks for your explanation, that was awesome. I started step by step and reached what I wanted but stuck in last steps. How can I number the circles?

void setup() {
  size(512,348);
}

void draw() {
  background(255);
  gradientCircle();
 
  }
  
void gradientCircle() {
  
  for ( int i=0; i < width; i=i+100){
     for ( int j=0; j<height; j=j+100){
      noStroke();
      fill(232,227,227);
       ellipse( i,j,60,60);
      fill(203,199,199);
      ellipse( i,j ,55,55);
      fill(180,177,177);
      ellipse( i,j ,50,50);
      fill(131,129,129);
      ellipse( i,j, 45,45);
      fill(98,95,95);
      ellipse( i,j,40,40);
      fill(0);
     ellipse ( i,j,35,35);
      }
    }
  }

here this is my code

int t = 0;
int max = whatever;
for( ... ){
for( ... ){
if( t < max ){
  circles!
} // or don't
t++;
}
}