Basic GUI in c++

Im new too C++/programming in general. Have a project from class where the extra credit is to create a graphical interface for our program, instead of ASCII art. The program is a game that checks for clusters of 3 of the same, and eliminates them.

The interface i would like to create is a 10x8 grid of multi colored squares. How would i do this? or is it too advanced for me
?
Easiest option is Qt to create interfaces with native C++

www.qt-project.org
I guess GUI wasnt the right word. What graphics library would i use, could graphics.h work.

All im trying to do is make a grid of 2d squares, how complicated of a task would that be, for someone who only knows how to program console applications
Here is a program that will print out 8 rows of 10 random-colored squares. Now your job, is getting your program to do the same.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Colored Blocks.cpp : main project file.

#include <conio.h>
#include <iostream>
#include <string>
#include <ctime>
#include <windows.h>

using namespace std;

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); // For use of SetConsoleTextAttribute()

void WaitKey();

int main()
{

	int len = 0,x, y;
	time_t t;
	srand((unsigned) time(&t)); // randomize using the time
		
	cout << endl << endl << endl << "\t\t\t"; // start 3 down, 3 tabs, right
	for ( x=0;x<8;x++)
	{
		for (y=0;y<10;y++)
		{
			SetConsoleTextAttribute(console, (rand()%16)*15); // set color for the next print
		cout << " ";
		}
		SetConsoleTextAttribute(console, 0); // set color to black background
		cout << endl << "\t\t\t"; // Start next line, 1 down, 3 tabs over
	}
	SetConsoleTextAttribute(console, 15); // set color to black background, white chars
	WaitKey(); // Program over, wait for a keypress to close program
}

void WaitKey()
{
	cout  << endl << endl << endl << "\t\t\tPress any key";
	while (_kbhit()) _getch(); // Empty the input buffer
	_getch(); // Wait for a key
	while (_kbhit()) _getch(); // Empty the input buffer (some keys sends two messages)
}
Qt is a good option, but it has a very large learning curve. A great GUI is SFML, easy to learn and fast. http://www.sfml-dev.org/
Topic archived. No new replies allowed.