CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: C++ Text based game..

Hybrid View

  1. #1
    Join Date
    Dec 2012

    C++ Text based game..

    Hello everyone, am new. I wondered if could help me get my head around the coding side of things.
    I have started to make a text based game for uni, its part of the course.
    I know what I need in it, I know what to do.. but for the life of me I cant code the thing.

    My first mission on this is to first display a random x and y coordinates of both you (the player and 10 enemies on a 10x10 grid)
    Bare in mind that i dont have to make the grid, just put if statements on the coordinates to limit the number from going any higher than 10.

    Here are the classes... I would i go about doing this?
    class Characters
    	int x,y; // co-ordinate position
    	Characters(int pos_x,int pos_y) {
    class Bunnymonsters : public Characters
    class Hero : public Characters 
    	//Create Hero

  2. #2
    Join Date
    Apr 2000
    Belgium (Europe)

    Re: C++ Text based game..

    C++ does not have a default means to directly access screen coordinates or to display text at a specific location.

    The Windows API does have functions to more directly control a console window, which among others includes querying the window size, the buffer size, changing both, accessing/reading/writing characters at a specific x,y coordinate, changing color and color background. But of course, this will make your game windows specific (it won't be recompilable and runnable for a linux machine).

    An alternative approach is to 'redraw' the entire playing field on every change, but that has some visual issues of it's own.

    depending on what you really want to do, it may be simpler even to write your own simple GUI based application.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)