Press up arrow?

How to do you make that so when you press the up arrow it couts something? and also, how to you overwrite a cout?
If you're using Windows you can try GetAsycnKeyState(): http://msdn.microsoft.com/en-us/library/windows/desktop/ms646293(v=vs.85).aspx
Your questions are suspicious. Are you sure you're not trying to make a console game? Because the console is not meant for games, and it is actually a bad idea to try to make a game in the console - it doesn't really teach you much in the way of actually making a real game.
Oh my god, is it just me, or does this guy read my mind?
Very very simple.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream.h>
#include <conio.h>

int main()
{	
		char a;
		a=getch();
		if(a == 0 || a == -32)
		{
			a=getch();
			if(a==72)
			{
				cout<<"UP!";
			}
		}
		return 0;

}


For special keys, two bytes are returned hence we have to use getch twice.
Your questions are suspicious. Are you sure you're not trying to make a console game? Because the console is not meant for games, and it is actually a bad idea to try to make a game in the console - it doesn't really teach you much in the way of actually making a real game.


I strongly disagree with that. Making console Rogue style RPGs are an amazing way to learn programming in general.
Last edited on
closed account (3qX21hU5)
It might be a way to learn programming in general but like he stated it is a very poor way to learn how to make a game. Games should not be in a console for several reasons. Yrs he will learn the basics of programming but almost nothing about GUIs or graphics or what goes into most games. Now Im not saying dont continue what your doing because anything that helps you learn is a good thing.
I strongly disagree with that. Making console Rogue style RPGs are an amazing way to learn programming in general.


I disagree with that.

Roguelike RPGs? yes. Lots of fun, and a really good learning curve (easy to do basics, but adding complexity can make it very challenging).

However... console? no.

When making a game, you're going to have to learn an API anyway. So you might as well learn a game API to make games, rather than learning to twist an unrelated API into making games.
Last edited on
I don't see how your twisting an unrelated API to do games that use to run on Dos in the console. I personally found no difficulty in doing so with both C# and C++. However, I did use XNA with C#, which is for games, and it is easy for every games but dos style games like an old rogue RPG.
The API for the Console was not made with the intention that you would use it to make games. Therefore console API is unrelated to games.
I fail to see your point...

DOS was not made with the intention to make games, yet, some of the best games I ever played were DOS games.

often times things are not used for the "correct" intentions. That's a part of this world... Einstein research was not in the intentions of creating nuclear weapons, yet it lead to such an end.
Last edited on
closed account (3qX21hU5)
I think your missing the point you can still make DOS style games without using the console and in the long run it will give you much more experience and a cleaner better game. The console is the worst playground for games
The point here is that if you want to learn to make a game, don't do it by making a console game.
Oria wrote:
I don't see how your twisting an unrelated API to do games that use to run on Dos in the console. I personally found no difficulty in doing so with both C# and C++.


I never said it was difficult. It's just a wasted step. If you're going to start making games, why not start with a game lib? It's easier, gives you more flexibility, and gives you a better understanding of how program flows in a game environment (which is actually very difficult from typical console program flow).

DOS was not made with the intention to make games, yet, some of the best games I ever played were DOS games.


Are you talking about DOS or the console? Because most DOS games did not use the console, they changed the video mode and ran like an actual game (see: Doom, XCom, Bio Menace, etc -- or just do a google image search of "DOS games")

Though he definitely should not be coding for DOS anyway. Nobody runs it anymore and Windows dropped compatibility for it years ago. So unless you want to run your stuff through an emu like DOSBox....

often times things are not used for the "correct" intentions.


That's true.. but a good programmer will use the right tool for the right job. There are numerous disadvantages to breaking away from the intended use of an API.
Are you talking about DOS or the console? Because most DOS games did not use the console


In that context I was referring to DOS. And the Console is just the evolution from DOS. True, DOS has been dropped and like you said, DOSbox is the only easy way to use most DOS games. There was a time where the DOS API was limited and good games were still created. Before Doom, etc. which is the 90s not the early 80s.

Regardless, I have used game made APIs with C#, not yet with C++. and all of the ones I've used so far were terrible for games which use no graphics. like a rogue style game. Maybe I should specify; I do not count newer rogue RPGs that use graphics as rogue game. However they can be classified the same. They aren't designed the same way.

The reason I believe console is fine, and I fail to understand "why not", is the fact that, most of these text based games give good practice on creating interesting algorithms. The real reason I ever did them in fact were to practice just that. Its not a waste of time, because it makes no difference what LIB or Language you use when you wish to increase your skills at creating better algorithms.

Its almost like people seem to think that programming is just in the languages... I think the languages are just tools, nothing more. If you don't know how to build a house, even if you know the tools, you'll never make a suitable house.
Last edited on
In that context I was referring to DOS. And the Console is just the evolution from DOS.


Err... the concept of a command prompt (aka: "the console" or "the terminal") predates DOS. It's been around since computers had keyboards.

DOS was an operating system (or rather a family of operating systems) which used a terminal as its primary means of user input. But it wasn't (and isn't) the only one -- nor was it even the first.

I know at least Unix was around before it (by about 10 years), but I'm sure there were others as well.

There was a time where the DOS API was limited and good games were still created. Before Doom, etc. which is the 90s not the early 80s.


DOS wasn't really a multitasking OS. Nor did it maintain exclusive control over hardware like modern OS's do. Programs written for DOS could (and often did) communicate directly with hardware via register accesses, rather than using an API provided by DOS.

Because of that, games (even in the early days of DOS) were never really limited by any API. Though, obviously those days are long gone. And hardware communication in user-level programs is now abstracted away for various reasons.

But really... none of this has anything to do with the original topic... which I can only assume was about the console and not about DOS at all. If you really are talking about DOS (which I suspect you aren't -- you must still be getting the two confused)... then you're absolutely insane to suggest he should write DOS games.

Maybe I should specify; I do not count newer rogue RPGs that use graphics as rogue game.


Then you're kidding yourself. They play exactly the same except they have graphics. That's like refusing to call modern Final Fantasy's RPGs because they're in 3D, and "real RPGs were 2D!"

Welcome to the future. Oh wait... not the future... I mean... 14 years ago. Yeah, welcome to 14 years ago.

most of these text based games give good practice on creating interesting algorithms


You learn all the same lessons from making an actual game. Except you're also making an actual game in the process. And therefore it's much more fun and it keeps you much more engaged, so you learn the lesson faster.

Its not a waste of time, because it makes no difference what LIB or Language you use when you wish to increase your skills at creating better algorithms.


He wants to make games. So why would you recommend anything other than a library that makes games? It doesn't make any sense.

If someone comes to you saying the want to learn to play the violin, do you tell them to learn how to play the cello first? Of course not. It's a wasted step.

Learn to do what you want to do. Don't waste time on intermediate steps that don't really do anything for you.

Its almost like people seem to think that programming is just in the languages


I fail to see what that has to do with anything.
Last edited on
Then you're kidding yourself. They play exactly the same except they have graphics. That's like refusing to call modern Final Fantasy's RPGs because they're in 3D, and "real RPGs were 2D!"


They do play the same, but adding graphics is a lot more work and takes away from practicing other functions of a game. and they are not the same, just like 3D RPGs and 2D RPGs are both RPGs (true), they are not the same. And because AAA games are mostly 3D, does not mean 2D games are obsolete. And there are still communities that support text-base games. see Rogue Basin: ( http://roguebasin.roguelikedevelopment.org/index.php?title=Main_Page ).

I don't really wish to argue anymore, I don't agree with you and you do not agree with me, so it will be pointless. All I know is that I learned a lot with the Console years ago and it made things easier for me once I started using XNA with C#. So am doing the same with C++. And will recommend something I know worked for me, just like you would recommend something which worked well for you. But hey, everyone learns differently.
All I know is that I learned a lot with the Console years ago and it made things easier for me once I started using XNA with C#.


I never said you wouldn't learn anything from working in the console. I said you should learn what your goal is and not treat the console like an intermediate step. If your goal is to make games, then make games. Don't make console programs.

But you're right. We're spinning our wheels here.
While we are at it though, what API should someone be using to do a text based RPG game with C++.

There was not many options in that regard for C#, but since I've changed my primary focus to C++, I would like to what I could or should be using.
closed account (3qX21hU5)
Just use something simple like SFML. It is quite easy to draw text, it also supports everything you would need in text based game audio if you want it, networking if you want more then one player, 2D and 3D graphics (If you choose to add them) ect. You could make a nice little text based RPG game with it. Also its very portable and would work well for you I think since it supports both C++ and C#
Last edited on
Topic archived. No new replies allowed.