Draw at a position

I am making a multiplayer game with a server, and decided that I want to be able to type stuff into the console like commands. I've been searching google for how to do the kind of things that I want. I want what you have typed to be displayed under the last thing that the server has outputted. So it would look something like this:

Created Server
Generating level...
Level Generation Complete
Blah joined the game!
:command typed here

This is what I have. The command is displayed at a position, but the position doesn't update whenever the server outputs something. How can I get the position of the next line in the console that is empty?

1
2
3
4
5
COORD coord;
coord.X = 0;
coord.Y = height;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
cout << ":" << typed << endl;
You are creating a game using the windows library in the console o.O

I would suggest some sort of graphics library it may save you a lot of coding.

As far as outputting to the next empty line, you may want to keep track of what all lines you output on.

Though I personally would make a queue (or stack if you want) to keep track of the messages. Then if there are too many there, remove the top most (queue) or bottom (stack). You would also know what line the message would be on (that is if you word wrap and add each new line to the container).

Anyways, good luck!
Oh no! I'm not making a multiplayer game in the console! That would be horrible... No just the server is in the console the client uses Allegro and ENet to connect to the server. Good idea with the queue. Just clear the screen and draw everything from the queue. I'll try that later.
Last edited on
Topic archived. No new replies allowed.