Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I couldn't test or modify the structure of the code yet, and this is still a very, very early build... if I don't attempt to include any graphics, the game executes just fine on a command line.
C++
#include <iostream>
#include <string>
#include <graphics.h>

int main()
{
    int gd = DETECT;
    int gm;
    initgraph(&gd, &gm, "C:\\TC\\BGI");

    arc(200, 200, 0, 130, 50);
    arc(150, 150, 0, 360, 10);
    arc(250, 150, 0, 360, 10);
    arc(200, 200, 0, 360, 5);

    getch();
    closegraph;

    int erick[2][6] = {{1,3,5},{2,4,6}};

    // 1,3,5
    // 2,4,6

    int juliett[3][6] = {{1,3,5},{2,4,6}};

    // 1,3,5
    // 2,4,6

    int elliot[4][6] = {{1,3,5},{2,4,6}};

    // 1,3,5
    // 2,4,6

    int paul[5][6] = {{1,3,5},{2,4,6}};

    // 1,3,5
    // 2,4,6

    int friedrich[6][6] = {{1,3,5},{2,4,6}};

    // 1,3,5
    // 2,4,6

    int name1;
    string age1;
    char initial1;

    cout << "naming game: type and guess the secret name to advance, if failure you see the credits!" << endl;
    cin >> age1 >> initial1 >> name1;

    cout << "type the secret name" << name1 << "starts with " << age1 << "the letter e" << name1 << endl;

    int name2;
    string age2;
    char initial2;

    cout << "stage 2" << endl;
    cin >> age2 >> initial2 >> name2;

    cout << "type the secret name" << name2 << "starts with " << age2 << "the letter j" << name2 << endl;

    int name3;
    string age3;
    char initial3;

    cout << "stage 3" << endl;
    cin >> age3 >> initial3 >> name3;

    cout << "type the secret name" << name3 << "starts with " << age3 << "the letter e" << name3 << endl;

    int name4;
    string age4;
    char initial4;

    cout << "stage 4" << endl;
    cin >> age4 >> initial4 >> name4;

    cout << "type the secret name" << name4 << "starts with " << age4 << "the letter p" << name4 << endl;

    int name5;
    string age5;
    char initial5;

    cout << "stage 5" << endl;
    cin >> age5 >> initial5 >> name5;

    cout << "type the secret name" << name5 << "starts with " << age5 << "the letter f" << name5 << endl;

}


In other words, the small window is blank (grey), and nothing happens if I attempt to use graphics.

What I have tried:

I tried to take the graphics coding away and it started working as a command line interface. Also attempted to modify the coding here and there, but it is mostly working at this point through CLI, just not GUI.
Posted
Updated 25-Oct-16 19:47pm
v3

1 solution

The graphics.h header file is for the Turbo C[++] graphics library for DOS. If you want to use that, you must build your program with Turbo C[++] and execute your program within DOS (boot into a DOS system or use a DOS emulator like DOSBox).

To create programs with graphical output when running on a windowed system you can

  1. Use the system dependant low level framework (e.g. Microsoft Windows API, X Window or Wayland with Linux)
  2. Use a high level framework like MFC or WTL for Windows or Qt, GTK+, wxWidgets for multiple operating systems

For an overview of GUI frameworks see List of widget toolkits - Wikipedia[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900