The Console is a Terrible Medium for Games

Pages: 123
All too often on these forums I see people asking how to either make a game in the console, or asking how to do a specific task related to game making in the console. Things like clearing the screen, repositioning the cursor, changing the font color, having the program run "in the background" so it doesn't wait for user input, etc.

The bottom line is the console is not designed for this kind of thing, and you shouldn't use it for these types of programs.

You can make it work, but the end result will be bad on many levels:

- you'll have hackish code that twists console I/O away from what it does normally to what you want it to do.
- you'll have to comprimise your goals to accomidate the console's limitations
- your program won't be as polished as it could otherwise be
- it will be much more difficult than the alternatives.


I'm writing this article in an effort to persuade people to move away from the console when they start making simple games.

In this article I use SFML in the example (get it at http://www.sfml-dev.org ). I like SFML because I find it to be particularly beginner friendly, but also very fast, well documented, cross platform, has an active userbase, and is actively being developed. However it is not your only option. Other libs are available, such as Allegro or SDL.

If you're interested in game dev, I recommend you get SFML and start playing around with it. You might have to wrestle with the install and getting it set up, but it's a one time process. Once you figure it out, you don't have to do it again, and you'll be able to make future games easily. A small price to pay.


And because it's more fun for me... I'm writing the article in Q&A fashion!

Q) But graphics are complicated. Isn't the console easier for beginners?

That first statement is a falacy. And no. You'd be surprised how easy simple graphical libs can be. With the right lib, drawing an image is as simple as this:

1
2
3
4
5
6
7
8
9
// load the image
sf::Image imagefile;
imagefile.LoadFromFile("myimage.png");

// put the image in a "sprite" (basically a rectangle of something we want drawn)
sf::Sprite mysprite(imagefile);

// draw that sprite to the screen
mywindow.Draw(mysprite);


The difficulties of graphics are grossly overestimated.


Q) But wouldn't it be better to start with the console, then take what I learned and move on to graphics later?

No.

Console development and game development are completely different worlds, with completely different styles.

About the only thing you'll learn by doing console dev first is language basics (what is a variable, what is a class, rules of C++, etc). But those basics are just as easy to learn with ANY target medium. The console is just the one people are introduced to most often because it's the only one the standard library supports.

Other things you learn from the console (how to structure the program's flow, how to poll and get user input, how to display things to the user) have little to no application in the game world. Games have to do it completely differently. You'll ultimately have to "unlearn" a lot of things the console taught you and relearn an entirely new way to do things. So you're better off just not wasting the step.

Q) But I don't want graphics. I just want ASCII symbols and a simple grid style map (for a rogue-like or something similar). Wouldn't the console be better?

Probably not. If you're using text for something graphics could represent, it's probably better (and just as easy) to use graphics.

If you really don't want to use graphics... like if you like the ASCII style... you can use the graphic lib and just draw ASCII symbols as graphics so it looks like you're printing text when you're really not.

That might sound stupid, but it offers many benefits:

- game libs have a more suitable approach to getting user input
- game libs have other features you might want, like background music or sound effects
- game libs don't have the same restrictions consoles do, like which colors can be displayed, and the resolution at which the game runs.

Q) But all I want is a simple text based adventure game where you type things like "move east" and it prints a description. Wouldn't the console be better for that?

Well you probably shouldn't be making that kind of game (see next Q). But for that... yes. The console would probably be easier. As long as:

- you are sure you don't want any accompanying graphics. Keep in mind you might change your mind later and want a simple picture of the current location to be shown above the description text.
- you don't want any BGM
- the game will be waiting for user input (it won't be "running in the background")

Q) Why did you say I shouldn't make a text based adventure game? What's wrong with them?

They're not easy to make. In fact they're one of the harder games you can make.

Parsing text input and making sense of it alone is difficult. Add onto that the heavy events and complexities involved in text based adventure games an you have a project that a beginner probably isn't equipped to handle.

Believe it or not, simple realtime action games with animation and graphics (like a simple galaga or space invaders clone) are tons easier to make.

Beginners want to try out the text based games because they think it will be easier because they think graphics are difficult. But they're mistaken!


Q) But I've tried and I don't understand animation, and I know how to do console stuff. Wouldn't it be better to just stick with what I know?

That's because you learned console programming and not game programming. Remember they're different worlds, and having some experience in one doesn't necessariliy prepare you for the other.

If you're already stuck in your ways and really don't want to learn something new, then fine. Do whatever is the most fun for you.

But if you find yourself asking questions about how to do things the console isn't designed to do... stop. Instead of learning how to do things the wrong way, why not learn how to do them the right way? I mean as long as you're learning new things....




Anyway that's about all I have to say. Hopefully I can just link to this post in threads which this comes up.
Last edited on
Haha. Seconded. It's about time someone wrote this.

-Albatross
closed account (S6k9GNh0)
Well, in the case of certain causes, like the bunny game I made awhile back, NCurses would be somewhat fitting.

However, I completely agree that it is restricting and could be much more flexible and feature-filled if one were to use something like SDL or SFML. As a matter of fact, I might try and show an example :D
Last edited on
I have to admit, that code for drawing an image in the console was pretty cool.
"cool"?

I thought it was disgusting. =P
Well, the human heart looks disgusting but I don't think you'd contest that the way it works isn't really cool.
Disch do you think I could repost this on another programming forum? I notice the question come up often there and thought it'd be cool if I could post this. Of course I will link to this thread and let people know I didn't write it, I just thought it was insightful.

I too having just begun C++ programming within the last 2 weeks have fallen under the impression that "Graphics" are extremely hard to do, but after reading your post and doing a few tutorials on my own... display a .bmp of "hello world" is not only just as simple as cout << , but it also looks cooler :P

Go right ahead. That'd be great.
+1 chrisname

I think graphics in console window is cool :) But yeah, nice article.
I recommend you get SFML and start playing around with it. You might have to wrestle with the install and getting it set up, but it's a one time process.


Well since you highly recommend SFML then perhaps you can post your experience in the installation process. What are the problem e.g you need some other libraries in higher version and how to resolve them so the SFML can be installed successfully.

Installation is quite important to developers especially for some libraries, they require you to install lotsa other dependency libraries which is a nightmare!

E.g You install that dependent library, message prompt you to install another dependent libraries for that dependent library. It is like a recursive libraries installation nightmare! And that is even before you get to install your original libraries as you are busy installing their dependencies :(
+1 computerquip

NCurses rocks for ASCII-based GUIs

I agree 100% - I am actually using NCurses for a real-time application which depends more on ASCII data (numbers) than bit-based graphics. By choosing NCurses, I restrict my degrees of freedom so I don't waste too much time on "unimportant things" like what font should I use, etc... ...instead, I can focus on core functionality: displaying numerical data efficiently to the screen. I can also just run my app through ssh and not worry about having a X-Windows client installation, etc...
sohguanh wrote:
Well since you highly recommend SFML then perhaps you can post your experience in the installation process. What are the problem e.g you need some other libraries in higher version and how to resolve them so the SFML can be installed successfully.


I would like to see this as well considering the difficulty I have had trying to install SFML.

I personally had very few problems install SFML on Mac OS X. The only real problem I had was that the project templates were pointing to directories different from the ones the instructions told me to put my libraries in.

-Albatross
I had no issues on Linux Mint or Arch Linux, all I did was type something like "apt-get install libsfml-dev" or "pacman -S libsfml". The only issues I had on Windows was that the statically linked libraries were not being linked so I had a bunch of undefined symbols. I got bored after about 5 minutes and just switched to Linux, though, so it was probably my fault.
Although I have (to my knowing) fully installed all SFML libraries, I still need something to kick me away from console applications (same goes for Qt4). I need to get more trusted with both of these to let the console go, I also need to know how to link them to their respective libraries, since this is one of the things that's holding me down. (I'm using Netbeans IDE with the C++ module installed on it.)
I used this tutorial to set it up. I guess the tutorial could be wrong...

http://cpp.wikicomplete.info/tutorial:setting-up-sfml
I didn't have any problems installing SFML on my machine, but I'm not on Windows =x
I had no issues installing it on my XP machine. Just installed it, then set the builds "extra libs" directories to include the correct library folders and it worked fine.
As said, I have fully installed it, and I can actually see the .h files and what not. However, whenever I try to compile I seem to get linker errors (and I hate the linker by itself, mainly because of inexperience).
Well are you linking to it?
Pages: 123