Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Borland Builder Graphics

  • 14-02-2006 09:13PM
    #1
    Registered Users, Registered Users 2, Paid Member Posts: 8,548 ✭✭✭


    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, Registered Users 2 Posts: 21 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, Registered Users 2, Paid Member Posts: 8,548 ✭✭✭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