Sign in to follow this  
XDaWNeDX

moving cursor in consol applications

Recommended Posts

Aardvajk    13207
Depends on the language. In C or C++ there is no standard way. The Win32 API exposes [url="http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx"]some methods to do this[/url] kind of thing or there is the highly regarded [url="http://www.gnu.org/software/ncurses/"]ncurses library[/url] that is platform independant.

Share this post


Link to post
Share on other sites
fastcall22    10845
Hidden
In standard C++, you can't. This kind of functionality is dependent on the operating system. For instance, with Windows, you can use the [url=http://msdn.microsoft.com/en-us/library/ms682073%28v=vs.85%29.aspx]Win32 Console Functions[/url]

Share this post


Link to post
XDaWNeDX    113
Yes, it's c++.

How would I use those console functions? I've already seen them but I have no clue how to use them properly. I suppose I'll just make a test application and see if I can't make it work somehow.

Share this post


Link to post
Share on other sites
XDaWNeDX    113
[quote name='Aardvajk' timestamp='1307098693' post='4819007']
[source lang="c++"]
void f()
{
HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);

COORD c;
c.X=19;
c.Y=8;

SetConsoleCursorPosition(out,c);
}
[/source]

Simples. :)
[/quote]


Mmk, thanks SOOO much.

I'm trying to make an RPG with moving characters and stuff in a console application. But whenever you push the up/left/down/right buttons the WHOLE screen re-writes itself which makes it kinda bleh...

Share this post


Link to post
Share on other sites
ApochPiQ    23061
You can find some decent (but not excellent!) examples of using the Windows console API [url="http://members.gamedev.net/bag-of-holding/CartRunner/index.htm"]here[/url]. The code was written in 3 hours so be warned, it isn't hugely pretty or necessarily the best example of how to do certain things. But it should at least get you started and give you a rough idea of how things could be done.

Share this post


Link to post
Share on other sites
XDaWNeDX    113
[quote name='ApochPiQ' timestamp='1307132604' post='4819206']
You can find some decent (but not excellent!) examples of using the Windows console API [url="http://members.gamedev.net/bag-of-holding/CartRunner/index.htm"]here[/url]. The code was written in 3 hours so be warned, it isn't hugely pretty or necessarily the best example of how to do certain things. But it should at least get you started and give you a rough idea of how things could be done.
[/quote]


Mm, yes, well what I currently have is as follows:
[url="http://www.barnumized.com/downloads/Release0.01.5.rar"]http://www.barnumize...lease0.01.5.rar[/url]
(up/down/right/left to move, space for pause menu/select)
Removed the AI because I'm doing other stuff right now, and when I'm testing it the monsters keep attacking me. D: Plus, all it really did was make them walk into walls.
That's basically MOST of my game. I HAVE made other updates since uploading it to my website though.

Although, what you've shown me has different colours, so I'll download it..
That's too in depth for me. Surely I could use it, and really make my game look good. But if I wanted to do that, I'd use allegro, or directx, or some form of graphics API.
The point of my game is to make it as simple as possible.
Using what Aardvajk told me. Thanks again Aardvajk!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this