0

I'm making Tetris game , and while displaying shapes on console i faced a problem; at first just displaying the shapes were all shifted to the left ignoring the space so i made a condition to move the cursor with the space so as to display the characters at the right place , but this seems to destroy the shape because i don't know the size of the pixels of the character.

void ANIMATION(int box[8][8])
{
    char ▊ = 219;
    double x = 20,y=30;

    for (int i = 0; i < 8; i++)
    {
        gotoXY(x,y);
        for (int j = 0; j < 8; j++)
        {
            if (box[i][j] == 1)
            {

                cout << ▊;
            }

            else
                gotoXY((x+=0.35), y);
        }
        y++;
        cout << endl;
    }
    x = 20;
    y = 30;
    Sleep(1000);

    for (int i = 0; i < 8; i++)
    {
        gotoXY(x, y);
        for (int j = 0; j < 8; j++)
        {
            if (box[i][j] == 1)
            {

                cout << ' ';
            }
            else 
                gotoXY((x += 0.35), y);

        }
        y++;
        cout << endl;
    }
    cout << endl;
    system("pause>null");
}

1 Answers1

1

This depends on the OS you are using:

In Windows you can find what the character size is by using GetConsoleFontSize function.

In Linux you may want to look at something like freetype

gyosifov
  • 2,825
  • 4
  • 21
  • 38