1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include <iostream>
#include <Windows.h>
void Box(int posX, int posY);
void posCursor(int x, int y);
int main()
{
// just a test code to move
// across 10 times.
for (int i = 0; i < 10; i++) {
system("cls");
Box(i, 10);
system("pause");
}
return 0;
}
void Box(int posX, int posY){
char box[7][5] = {
{ '\xdb', '\xdb', '\xdb', '\xdb', '\xdb', },
{ '\xdb', ' ', ' ', ' ', '\xdb' },
{ '\xdb', ' ', ' ', ' ', '\xdb' },
{ '\xdb', ' ', ' ', ' ', '\xdb' },
{ '\xdb', ' ', ' ', ' ', '\xdb' },
{ '\xdb', ' ', ' ', ' ', '\xdb' },
{ '\xdb', '\xdb', '\xdb', '\xdb', '\xdb', }
};
for (int rows(0); rows<7; rows++){
for (int columns(0); columns<5; columns++){
posCursor(posX + rows, posY + columns);
std::cout << box[rows][columns];
}
std::cout << std::flush;
}
}
void posCursor(int x, int y)
{
COORD coord;
coord.X = x, coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
|