how to correctly spawn objects in raylib?

I was creating a simple game where you are a ball, and little rectangles spawn from above and you must not collide with them. I encountered problems with the spawner because i don't know how to mantain an object after drawing it. Does someone know how to solve it?


       Rectangle rettangolo = { randomNumber, screenHeight / 2 - 90,10,200 };
       
           
       if (((framesCounter / 120) % 2) == 1)
       {
           randomNumber = GetRandomValue(0, screenWidth);
           framesCounter = 0;
           rettangoli ++;
           

       }

       
       // Draw
       //----------------------------------------------------------------------------------
       BeginDrawing();
       
       DrawCircleV(posizioneCerchio, raggio, SKYBLUE);
       
       for (int i = 0; i < rettangoli; i++)
       {
           DrawRectangleRec(rettangolo, RED);
       }
           
       
       
       ClearBackground(RAYWHITE);

       

       EndDrawing();
       //----------------------------------------------------------------------------------
   }

   // De-Initialization
   //--------------------------------------------------------------------------------------   
   CloseWindow();        // Close window and OpenGL context
   //--------------------------------------------------------------------------------------

   return 0;
}

 
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum