Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Borland Builder Graphics

Options
  • 14-02-2006 9:13pm
    #1
    Registered Users Posts: 8,438 ✭✭✭


    Hi, I'm working with Borland Builder 6 and i'm trying to create a form that will display a checkerboard with checkers on it. I can display the 8x8 grid OR the circles but i can't seem to get the circles to appear on the checkerboard. If anyone knows if i need a Property or something to do, i'd hugely appreciate the help!
    p.s. this is in C++

    This is what i have:


    int width = ClientWidth/8;
    int height = ClientHeight/8;
    int startX = 10;
    int startY = 10;
    int color = 0;
    int count;
    int row;




    for (count = 0; count < 8; count++)
    {//Start of big for

    if (width < height)
    height = width;

    else
    width = height;
    startX = 10;

    if (count == 1 || count == 3 || count == 5 || count == 7)
    color = 1;

    else
    color = 0;


    for (row = 0; row < 8; row++)
    {//Start of small for
    if (color == 1)
    {//Start of if
    Canvas->Brush->Color = clPurple;
    color = 0;
    }//Finish of if


    else if(color == 0)
    {//Start of else
    Canvas->Brush->Color = clYellow;
    color++;
    }//Finish of else
    Canvas->Rectangle(startX, startY, (startX + width), (startY + height));
    startX = startX+width;
    }//Finish of small for
    startY = startY+height;
    }//Finish of big for






    for (count = 0; count < 8; count++)
    {//Start of circle for

    if (width < height)
    height = width;

    else
    width = height;
    startX = 10;

    if (count == 1 || count == 3 || count == 5 || count == 7)
    color = 1;

    else
    color = 0;


    for (row = 0; row < 8; row++)
    {//Start of small for
    if (color == 1)
    {//Start of if

    Canvas->Brush->Color = clRed;
    Canvas->Ellipse(startX, startY, (startX + width), (startY + height));
    color = 0;
    }//Finish of if


    else if(color == 0)
    {//Start of else
    color++;
    }//Finish of else

    startX = startX+width;
    }//Finish of small for
    startY = startY+height;
    }//Finish of circle for


Comments

  • Registered Users Posts: 18 suavek


    You just have to reset the startY variable to 10 before entering the circle loop. By the way, it's a good thing(tm) to declare the variables only for the scope they're actually used in:
    // bad
    // int row;
    // for (row = 0; row < 10; row++)
    //      ....
    
    // good
    for (int row = 0; row < 10; row++)
       ..do stuff..
    


  • Registered Users Posts: 8,438 ✭✭✭RedXIV


    Cheers mate, feeling a tad thicker but the relief compensates




    Just come across something that i'd really like a bit of advice in, if anyone is familiar with Borland Builder, maybe they could explain to me why saving something as a project file is so damn volitile!
    At least 8 of my projects have lost their .cpp files and i have no idea why, i either get a blank .cpp file or this nonsense:


    //


    #include <vcl.h>
    #pragma hdrstop
    //
    WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
    try
    {
    Application->Initialize();
    Application->CreateForm(__classid(TCheckers), &Checkers);
    Application->Run();
    }
    catch (Exception &exception)
    {
    Application->ShowException(&exception);
    }
    catch (...)
    {
    try
    {
    throw Exception("");
    }
    catch (Exception &exception)
    {
    Application->ShowException(&exception);
    }
    }
    return 0;
    }


    anyone knows why, i'd really appreciate the help


Advertisement