after searching around on if there were ways to 'specify' the insertion point of the cursor (with pricision) I stumbled upon the gotoxy/SetConsoleCursorPosition function or class thing, lol, sorry dont know what to call it.. ,
here it is and what it does as best I understand:
It uses a CLASS called "COORD" found in the <windows.h> header, so you'll have to #include it.
Out in the global scope create the function below. I'll add comments to it
- Code: Select all
void gotoxy ( short x, short y )
{
COORD coord = {x, y};
SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), coord );
}
-----------------------------------------------------------------------------------------------------------------------
I'll try to define what it does:
-----------------------------------------------------------------------------------------------------------------------
void gotoxy ( short x, short y )
/*these are going to be the x and y coordinates of the cursor, assuming one character occupies 'one' grid location.
so your console screen is basically a black grid (with the lines imvisible). I guess its short because console screens dont
get pretty big. the top most leftmost point (or square) of the console window is (0,0) and x increases horizontally and y
increases vertically.*/
{
COORD coord = {x, y};
/* Here they summon the class COORD and create an instance of it that they chose to call 'coord'.
then coord is assigned the values x and y. (btw dont mess with any of the syntax or names unless you are uber pro)
*/
SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), coord );
/*
so here im assuming the header window.h declared a function called SetConsoleCursorPosition (blah blah);
and now we're summoning it.
*/
}
-----------------------------------------------------------------------------------------------------------------------
How to Use it
-----------------------------------------------------------------------------------------------------------------------
As you could see, to use it in your function all you need to do is
-#include <windows.h>
-copy and past the function " void gotoxy ( short x, short y ); " to the code. preferably free (in the global scope)
-then call that function whenever you want to set the cursor position. making sure you feed it the x , y values you want
I looked around for a long time and all mentions of this was a bit technichal and not straight forward, so that why I take the laborious time to add it to our archive here XD, in such detail. (only need to do it once LOL)
So now the knowledge is yours o mighty noob. I can see 'so many' uses for this. lol
Some of you know I'm working on an "ASCII APARATUS" for generating text graphics, well this right here, will revolutionize it muahahaha. check the full programs section if I make an update to it soon.
I dont have time to proof read this for typos. so tough and sorry if ther are eny
