How to make a UI in C++ for a text based game.

This is a discussion on How to make a UI in C++ for a text based game. within the Game Programming forums, part of the General Programming Boards category; OK, I have already poste dthis just never got my exact answer. I've been looking through books and google and ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Location
    Usa, Pa
    Posts
    39

    How to make a UI in C++ for a text based game.

    OK, I have already poste dthis just never got my exact answer.


    I've been looking through books and google and still cannot find out how to make a UI in C++ for a text based game.



    1 Big Text Box - 75% of the screen. Shows the world description, movement, everything relating to the in game play.

    1 Smaller text box below the main text box for user data entry (ie. chat text, movement, emotes, whatever) Takes up about 2% of the screen

    1 frame - 23% of the screen, right side and runs parallel to the main text box, lists all player stats, inventory, etc. everything player related goes here.


    Now I am still pretty new to C++ and just want to build a nice portfolio of my own online text based game.

    I want to start out building the libraries as I go forth with this project.

    If someone could help me it'd be so apperciated!!

    I am using Dev-C++ 5. I can use MSVC++ 2005 EE if needed.

    Please do not suggest using Windows UI. It's not very user friendly with games.

    Thanks!

    ~ Tyler
    Last edited by TylerMoyer; 07-12-2007 at 02:49 PM. Reason: Added some things

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    43
    Try searching on google for ncurses, that might be what you want?
    Last edited by fractality; 07-12-2007 at 02:51 PM. Reason: typo

  3. #3
    Registered User
    Join Date
    Jun 2007
    Location
    Usa, Pa
    Posts
    39
    Quote Originally Posted by fractality View Post
    Try searching on google for ncurses, that might be what you want?
    As I stated, I'll be building my own. I need help finding an article or someone who can just help me out with how to do it.

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    43
    In what environment do you want to show the text? DOS, *nix shell, any kind of rendered window? C++ has no native definition of any terminal...If rendering in an OpenGL window is ok then I might be able to help you to do it...
    (I'm a linux/OpenGL kind of guy, can't help with Windows only stuff =( )

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    First of all, read this. Creating a user interface in C++

    Since you're using Dev-C++, you can either use the Borland-compatible conio.h functions like gotoxy(), getche(), clrscr(), etc, or you can use the Windows functions that the conio.h functions are implemented with. Adrianxw's tutorials that I linked to in that other post are a good read.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Registered User
    Join Date
    Jun 2007
    Location
    Usa, Pa
    Posts
    39
    I am looking to create some thing like this,

    1 Big Text Box - 75% of the screen. Shows the world description, movement, everything relating to the in game play.

    1 Smaller text box below the main text box for user data entry (ie. chat text, movement, emotes, whatever) Takes up about 2% of the screen

    1 frame - 23% of the screen, right side and runs parallel to the main text box, lists all player stats, inventory, etc. everything player related goes here.
    http://www.tidesofwarinc.com/doimage...lient-Pic1.JPG

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    In text mode? 80x25? Okay.

    Do you want to use colour? Do you want to re-paint the whole screen each frame, which is easy to do but very inefficient? Do you want to keep track of what is displayed on the screen, and use gotoxy() or something to only change the characters that need changing (which is a very good way to do it)?

    Why are you adverse to using an external library? ncurses or pdcurses would serve you well. You wouldn't have to worry about many things that you would otherwise have to, and your program would probably be more portable, too.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    Registered User
    Join Date
    Apr 2006
    Posts
    43
    Hmm, I think you might find out that it's more problematic than you first thought to do a text only user interface. Don't let the ease by which you usually input text fool you into thinking that it's easier to do than drawing the UI in OpenGL or other graphical toolkit.

    Think about how you are going to resolve the issues that DWK points out and also how to deal with the user resizing the text window.

    If you want to build up a portfolio of code, aim at learning useful industrial toolkits instead of implementing everything yourself. Even though it's always good to try new things and experiment, it might be wiser to skip the hardest parts for now and do functionality first?

    Wrap the usage of another toolkit like ncurses and implement your game, then when you know what you want, try to replace ncurses with your own implementation, if you do it this way it's less chance of your project running out of steam before being useful to you...You will also have time to figure out more about how to effeciently program a text ui and learn some from the use of ncurses.

    Good luck,

    /f

  9. #9
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Why doesn't anyone here just code a simple Windows shell in which to create their text-based games. It's so much easier than console and can be setup in a fourth of the time. And you have all the text rasterization power of Windows at your fingertips.

    The only downside is your game only runs on Windows.

  10. #10
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    Of course you could just code something similar in SDL. I've run across a game or two that has done that.

  11. #11
    Registered User
    Join Date
    Jun 2007
    Location
    Usa, Pa
    Posts
    39
    Figured it out.

  12. #12
    Registered User
    Join Date
    Jul 2007
    Posts
    1

  13. #13
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    That's nice and all except it lacks double buffering and you can't guarantee that a user won't resize his console window.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. text based mmo type game.....
    By SONAR in forum Game Programming
    Replies: 0
    Last Post: 12-09-2008, 04:17 AM
  2. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-25-2006, 11:14 PM
  3. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 06:18 AM
  4. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 09:45 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 06:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21