my gaming past, present and future
Thursday May 17th 2012

Interesting Sites

Insider

Archives

Text Console Library

text maze console libraryWhen you first start coding in C/C++ your first programs are done in the console. The problem with the console nowadays is that the conio.h library no longer lets you do all the fun things it used to, like set the text color, set cursor position, clear the screen, etc. You can only print text out in a stream just like the olden days of the 70′s and teletype printers. Lame.

This is the problem that all beginning game coders run into and it really takes some of the fun out of learning when you can’t even sit down and try to write Pac-Man in text mode.

So I poked around and found a little snippet of code, added my own functions and now I have a nice little text console library you can use. Just add the console.h and console.cpp files into your empty Win32 console project and you can actually make text games. Without this kind of library you can’t really make any kind of fun text game other than an adventure.

I threw together a short sample program to demonstrate what you can do. It’s a simple maze that has a random exit (‘X’winking in it; touch it and you win. The source is named main.cpp. The game? ULTRA-X OF THE FORBIDDEN REALM!

To add even cooler stuff to your console games you should download FMOD and link it into your project. Instructions on how to do this are on FMOD.ORG and are easy to follow. Imagine that – a text game with background music and sound effects.

Grab the code here (Windows only)

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Reader Feedback

6 Responses to “Text Console Library”

  1. Dimi says:

    Thanks for this. I did like you say and downloaded fmod and created a little snake game within some hours. I remember the times where I started coding with an Amstrad CPC and the first games were text adventures.
    I posted the game on my blog refering to your site and this article.
    Hope you don’t mind.

    Greetings Dimi

  2. jacob says:

    hi john ,

    great stuff!
    how do i build this on xcode im a total newbie on this one happy

    thanks,
    jacob

  3. Jonthe says:

    @Jacob

    If you haven’t figured yet, you cannot build this library under XCode due to the fact that the library uses Windows specific functionality. You could always run Windows (+ compiler tools) on a Mac through BootCamp or virtualization software though.

  4. I’m working on developing a blog like Text Console Library | planet romero. I still have a way to go, and certainly don’t yet get the traffic you appear to have. when you can, please give me some comments on http://www.fark.com as I know it needs a tune up. Nice site, sincerely, Jordan Bridges

  5. Hugo Lacombe says:

    Thanks Romero for replying my tweet! This will be really useful xD

Leave a Reply