void DisplayMap(Character *teamOne, Character *teamTwo, int soldiers)
{
char* map[24][78];
for(int x = 0; x < 24; ++x)
{
for(int y = 0; y < 78; ++y)
{
map[x][y] = " ";
}
}
for(int i = 0; i < soldiers; ++i)
{
map[teamOne[i].iX][teamOne[i].iY] = "@"; // Was @ using " " as Temp
map[teamTwo[i].iX][teamTwo[i].iY] = "%";
}
for(int x = 0; x < 24; ++x)
{
for(int y = 0; y < 78; ++y)
{
std::cout << map[x][y];
}
std::cout << std::endl;
}
system("Cls");
}
I know this isn't perfect but because of the way it needs to be displayed i'm not sure of how else I can do it. It works fine just the bottem right of the screen flickers a heck of a lot due to the constant amount of loops.
I'm searching it up now. I understand what it is in a sence as a mate of mine used it once for the same time of thing - sadly we are no longer in touch so i'm unable to ask him for help heh. Anyway main point being. How do I know if my console supports it?
Well I did find a site for the buffer and all.. Only problem is - it's the only one i could find that fit what i wanted to do.. Yet all there links are broken. Oh well not to important.
What do i put inside the SetConsoleCursorPosition()? Haha and yeah don't worry I didn't include the above in my code - just not sure what to put inside - say if i want the cursor to go back to the top left at position 0, 0?
Now you have the ability to move the cursor, it might (depending on the number of items on the map) be quicker to update the map rather than redraw the whole map
IE Just update the points that change.
The balance is the overhead of moving the cursor vs the reduced number of screen writes. Note that you will have to write to both the old (to remove it) and new positions for each 'thing'.
All is good i re-rote some of the display and changed my other functions - no flickering or lag if anything its to fast now ahah. But its sweet now nice and smooth :D Thanks Guys
You probably had scrolling because by default the console screen buffer tends to be larger than the window can display (giving those nice scrollbars on the side and/or bottom).
When your game starts, you should resize the screen buffer down to what your program expects to use somewhere in the initialization. You can use GetLargestConsoleWindowSize() to see what your current constraints are. Then use CreateConsoleScreenBuffer() to create a couple of buffers that are the size you need. Set one of them to the currently displayed buffer with SetConsoleActiveScreenBuffer().
Thereafter, draw in the currently inactive buffer, and when you are ready to update, switch the active/inactive buffer. (This is called double-buffering, and makes things look sweet.)
Before terminating, restore the original screen buffer to the active state, and destroy the two you created with CloseHandle().