Hi Everyone...!!

Last Week, I Was Assigned A Project Of Building A Mine Sweeper Game In Console.!! I Start Working On It But I Don't Have Any Idea From Where Should I Get Started..!! I Want To Add Some Simple Graphics In My Game, But First I Want To Make Simple Game...!! For That Purpose, I Figure Out Some Task For The Project..!!

1) Make A Board On The Console (2x2, 4x4, 8x8, 16x16)
For That Purpose I Used The Following Code:

#include <iostream>

using namespace std;

int main()
{
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            i % 2 == 0 ? cout << "  |" : cout << "---";
        }
        cout << endl;
    }

    return 0;
}

It Simply Prints The 4x4 Board On The Screen...!! Although, I Am Not Satisfied With The Pattren...!!

2) Now, After That I Wanted To Get Input From The Keyboard And Move The Cursor And I Did So By Using gotoxy() Function..!!
But The Real Problem Is Get Started Now..!!
How Can I Restricted The Movement Of The Cursor And Determined At Which Point/Pixel User Hit Any Key..!! And That Area In Within The Range Also...!!

3) I Want To Add Some Graphics Also In The Game But As Far As I Know, Graphics In C++ Are Much More Difficult As Compared With Python, Java, C#...!! Is There Any Way To Learn About C++ Graphics Within 3-4 Weeks That Are Enough For This Game..!!

4) I Know The Following Topics Of C++

  1. Functions!
  2. Arrays!
  3. Vectors!
  4. Pointers!
  5. File Handling!
  6. Structure Programming!
  7. OOP (A Little Bit)

Thanks In Advance For Answering...!!

How Can I Restricted The Movement Of The Cursor And Determined At Which Point/Pixel User Hit Any Key..!!

As you record the key-strokes to move the cursor, first check that the movement is allowed (remain within the ranges of x and y values), and, of course, keep track of the coordinates of the cursor, you can use those coordinate values when you get the "hit any key". Please show your code if you want more detailed explanation.

Graphics In C++ Are Much More Difficult As Compared With Python, Java, C#...!!

The difficulty mainly comes from the fact that graphic user interface libraries are not part of the standard library in C++ (as they are with some other languages). Being primarily a general-purpose system infrastructure programming language, having a GUI library in its standard library would be a really bad idea. However, there are many external libraries that can be used in C++ for this purpose, most of which are just as easy to use as in other languages, in fact most of the GUI tools of other languages are written in C++ with a thin layer that give you access to them.

Is There Any Way To Learn About C++ Graphics Within 3-4 Weeks That Are Enough For This Game..!!

It would seem to me like basic console graphics is probably enough for this game. The thing is, what you can do in the console is quite limited, so I guess you want to move to a windows-style GUI. The problem with that is that it is quite a significant step from simple console graphics. First, it will require that you learn how to use an external library (specify include folders, include the headers, specify link folders, specify link libraries which you need to install, etc.). Second (and this is true for any language), most GUI libraries are quite a bit more complex than what you'd really want for your simple purpose (with great power comes great complexity). So, you'd probably have to go through some tutorials to learn the ropes, and hope that one of the tutorials closely matches the kind of thing you want to do. Third (and this is also true for any language), most GUI tools are object-oriented and have the minimal requirement that you be at ease with that. And finally, if this is for a school assignment (as I assume it is), then you're going to require your teacher / grader to install that external library too in order to run / compile your code for verification and testing, which they typically don't want to have to do at this level.

The simplest library I can suggest for simple GUI graphics like you need is SDL which is widely used for this kind of simple programs (i.e., 2D graphics, drawing some basic graphics and images). A more complete GUI tool that I could recommend is Qt which is probably one of the easiest and most popular full-fledged GUI libraries and toolsets in C++. If these can be learned in 3-4 weeks, I don't know, that depends on you. Without a good understanding of OOP, this might be hard. I know I was able to pick up all I needed to learn to be functional with Qt in about one hour, but that's with years of prior experience with C++ and a few other GUI tools. You can certainly try some tutorials and see where it leads you, but I would try SDL first, maybe these simple game tutorials will help.

I Know The Following Topics Of C++:
...
OOP (A Little Bit)

I think you still have bit to go before you should move on to GUI libraries. The main thing is just to get a good handle on OOP because that's the name of the game in GUI programming (in any language).

Yes, You Are Right! I Have No Good Experience In OOP! Currently I Am Taking A Course From RICE Univerist About Graphics In Python And I Hope That This Course Will Help Me In Learning Graphics In C++ (May Be I Am Wrong)! Now I Used The Follwoing Code In Order To Move The Cursor In Console!

#include <iostream>
#include <windows.h>
#include <conio.h>
#include <cctype>

using namespace std;
void gotoxy(int, int);

void gotoxy (int x, int y)
{
    COORD coord; // coordinates
    coord.X = x; coord.Y = y; // X and Y coordinates
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); // moves to the coordinates
}

int main()
{
    int x = 0;
    int y = 0;

    while(true)
    {
        char ch;
        ch = getch();
        if (toupper(ch) == 'W')
            gotoxy(x, --y);

        else if (toupper(ch) == 'S')
            gotoxy(x, ++y);

        else if (toupper(ch) == 'A')
            gotoxy(--x, y);

        else if (toupper(ch) == 'D')
            gotoxy(++x, y);


        else if (VK_RIGHT)
            gotoxy(++x, y);

        else if (VK_LEFT)
            gotoxy(--x, y);

        else if (VK_UP)
            gotoxy(x, --y);

        else if (VK_DOWN)
            gotoxy(x, ++y);

        else if (ch == '\b')
            gotoxy(--x, y);

        else if (ch == '\r')
            gotoxy(x, ++y);

        else if (ch == '\t')
            gotoxy(x += 4, y);
    }

    return 0;
}

It Works Fine On (A,S,D,W) But Filed On Arrows Keys As It Is Always Move Forward If I Press Any Arrow Key! Now, How Can I Restrict The Movement! It Is My Next Assignment!

The difficulty mainly comes from the fact that graphic user interface libraries are not part of the standard library in C++ (as they are with some other languages).

I Talk To My Teacher And He Said That For Now Forgot About The Graphics! First Make It Simple But Cursor Movement And Restrictions Are Allowed And Necessary For This Game..!!

Now, I Hope That My Question Is Much More Clear..!!
Thanks To mike_2000_17, Your Answer Helped Me A Lot, As Now I Am Clear That What Should I Do And For Sharing Some Links On GUI...!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.