So that was a lie.


       #include "raylib.h" //  "" are for external libraries and needs a .h ext <> are for c++ included library




 int main ()
{

//Window
    int width   {750}; // X
    int height  {450}; // Y
    InitWindow(width,height, "Murphy's Window"); // needs inputs ( width, height, title)

// text
    int txt_pos_x  {width/2};
    int txt_pos_y  {height/2};
    int txt_f_size {20};
    

//Circle
    int posX {width/4}; // circle
    int posY {height/2}; // circle
    float radius{20.0f}; // circle
    
    // Edges of Circle
    // its center pos +/- radius 
    float cirLeft {posX  -  radius};
    float cirRight{posX  +  radius};
    float cirDown {posY  +  radius};
    float cirUp   {posY  -  radius};


//Square
    int squX     {(width/2)-25};
    int squY     {0};
    int squWidth {50};
    int squHeight{50};

    //Square Edges
    // its center starts at top right so to find edges its just two?
    int squRight {squX + squWidth};
    int squLeft  {squX};
    int squUp    {squY};
    int squDown  {squY+squHeight};

    //point circle
    
    int rngPosX{GetRandomValue(radius,(width-radius))}; //x left/right
    int rngPosY{GetRandomValue(radius,(height-radius))}; //y up/down

    //point collision

    int pointUp    {rngPosY-radius};
    int pointDown  {rngPosY+radius};
    int pointLeft  {rngPosX-radius};
    int pointRight {rngPosX+radius};

//Collision Detection
/*


(squDown >= cirUp) && (squUp <= cirDown) && (squLeft <= cirRight) && (squRight >= cirLeft)


*/

//Game
    int pointsCount{};
    int directionX{10};
    int directionY{10};
    bool collision_detected = 
                        (squDown >= cirUp)    && 
                        (squUp <= cirDown)    && 
                        (squLeft <= cirRight) && 
                        (squRight >= cirLeft);
    bool points=
        (pointDown >= cirUp)&&
        (pointUp <= cirDown)&&
        (pointLeft <= cirRight)&&
        (pointRight >= cirLeft)
    ;
    
//Input    
    float speed{6.9};



    
    SetTargetFPS(60);
    while(WindowShouldClose() != true )  // WindowsShouldClose() is a Boolan Method(?) that returns False UNLESS X or Escape is pressed
    {
        if(IsKeyDown(KEY_RIGHT) && posX <= (width - radius))    { posX +=  speed;}
        if(IsKeyDown(KEY_LEFT)&& posX   >= (0 + radius))        { posX -=  speed;}
        if(IsKeyDown(KEY_DOWN)&& posY   <= (height - radius))   { posY +=  speed;}
        if(IsKeyDown(KEY_UP)&& posY     >= (0 + radius))        { posY -=  speed;}

        if(IsKeyPressed(KEY_A) && collision_detected)
        { 
            posX = width/4;
            posY = height/2;
            collision_detected = false;
            squX = height/2;
            squY = width/2;
            pointsCount= 0 ;
            
         }



        BeginDrawing();
        ClearBackground(DARKGRAY);
        // Begin

        //Gameover 
            if(collision_detected) //implied true
            {
                DrawText("Game Over Man!!", txt_pos_x, txt_pos_y, txt_f_size, BLACK);
                DrawText(TextFormat("Score: %d", pointsCount),txt_pos_x, txt_pos_y+25, txt_f_size, BLACK);
                DrawText("Press A to restart.", txt_pos_x, txt_pos_y+50, txt_f_size, BLACK);
            }
                else
                {
                    DrawCircle(posX, posY, radius, BLUE);
                    DrawRectangle(squX, squY, squWidth, squHeight, RED);
                    //point square
                    DrawCircle(rngPosX,rngPosY, radius, YELLOW);
                    if(points)
                    {
                        rngPosX = GetRandomValue(radius,(width-radius));  
                        rngPosY = GetRandomValue(radius,(height-radius));
                        pointsCount +=1;
                        points = false;
                    }
                    DrawText(TextFormat("Score: %d", pointsCount),25,25,20,BLACK);
                    //update edges     you can update stored variables each loop0
                    cirLeft = posX  -  radius;
                    cirRight= posX  +  radius;
                    cirDown = posY  +  radius;
                    cirUp   = posY  -  radius;

                    squRight =squX + squWidth;
                    squLeft  =squX;
                    squUp    = squY;
                    squDown  = squY+squHeight;

                     pointUp    =rngPosY-radius;
                     pointDown  =rngPosY+radius;
                     pointLeft  =rngPosX-radius;
                     pointRight =rngPosX+radius;

                    collision_detected = 
                        (squDown >= cirUp)    && 
                        (squUp <= cirDown)    && 
                        (squLeft <= cirRight) && 
                        (squRight >= cirLeft);

                    points=
                            (pointDown >= cirUp)&&
                            (pointUp <= cirDown)&&
                            (pointLeft <= cirRight)&&
                            (pointRight >= cirLeft);
                    // move axe
            
                    squY += directionY ;  // adds an amount to the square's location every frame, causing the square to move down
            
                    if(squY > (height-50) || squY < 0)  // if the square's coords are greater than the height of the window
                        {
                        directionY = -directionY; // reverses direction somehow. still magic.
            
                        }


                       squX += directionX;
                   if (squX < 0 || squX > (width-50))
                    {
                        directionX = -directionX;
                    }

                    
                }



        // End
        EndDrawing();
    }



    
}

—ComRadical, 1-28-24

1-29-24