- #1
Max0007
- 66
- 1
Homework Statement
I work on Microsoft Visual studio 2010 on Win7.
Ok so let me explain the problem here, The functions works very good to position my printf in X and Y on my screen ONLY when my 2D Array labyrinth Map is NOT printed on the screen.
But once I printf my Map on the screen I cannot position the printf in X and Y.
This is the current code I use to position my printf and only works when my Map is not printed on the screen.
gotoxy(posx,5); clreoscr();
textcolor(15);
posx = printf("\nSpeed of Character: %d / %d",speed, m1);
textcolor(15);
posx = printf("\nSpeed of enemie: %d / %d", speed_e, m2);This is the functions I have to use to give my printf a position on my screen.
----------------------------------------------------------------------------------------------------------------------------
void gotoxy(int x,int y) //positions text cursor at (x, y) screen position
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo; //variable declarations
HANDLE hConsoleOut;
hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo);
csbiInfo.dwCursorPosition.X = x; //cursor position X coordinate
csbiInfo.dwCursorPosition.Y = y; //cursor position Y coordinate
SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition); //set cursor at the given screen coordinate
}/*-------------------------wherex()------------------------------------*/
int wherex() //returns current text cursor (x) coordinate
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo);
return csbiInfo.dwCursorPosition.X;
}
/*-------------------------wherey()----------------------------------*/
int wherey() //returns current text cursor (y) coordinate
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo);
return csbiInfo.dwCursorPosition.Y;
}
Homework Equations
n/A
The Attempt at a Solution
N/A