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
?
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
// Colored Blocks.cpp : main project file.
#include <conio.h>
#include <iostream>
#include <string>
#include <ctime>
#include <windows.h>
usingnamespace 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)
}