Have created a simple bingo game, I'm going to add color later (why I have used the SetConsoleTextAttribute). The problem is that the X i replaced by 88, I know why (I think), it's becuse it's a int and not a char, but when i tried to put in (char) before the Number[1] = 'X';
it doesn't work
#include <iostream>
#include <time.h>
#include <windows.h>
using namespace std;
HANDLE SetColor(
HANDLE console,
int fg = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY,
int bg = 0)
{
if(console == NULL);
console = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(console, fg | bg);
return console;
}
int main()
{
doubleNumber[16];
char StrikeHit('X');
srand(time(0));
bool GameOver(false);
bool GameOverWin(false);
cout << "enter 16 numberss between 10-40" << endl;
cin >> Number[0];
cin >> Number[1];
cin >> Number[3];
cin >> Number[4];
cin >> Number[5];
cin >> Number[6];
cin >> Number[7];
cin >> Number[8];
cin >> Number[9];
cin >> Number[10];
cin >> Number[11];
cin >> Number[13];
cin >> Number[13];
cin >> Number[14];
cin >> Number[15];
int k = 51;
while(k) {
do {
cout << "-+-+-+-+-+-+-" << endl;
cout << "|" << Number[0] << "|" << Number[1] << "|" << Number[2] << "|" << Number[3] << "|" << endl;
cout << "-+-+-+-+-+-+-" << endl;
cout << "|" << Number[4] << "|" << Number[5] << "|" << Number[6] << "|" << Number[7] << "|" << endl;
cout << "-+-+-+-+-+-+-" << endl;
cout << "|" << Number[8] << "|" << Number[9] << "|" << Number[10] << "|" << Number[11] << "|" << endl;
cout << "-+-+-+-+-+-+-" << endl;
cout << "|" << Number[12] << "|" << Number[13] << "|" << Number[14] << "|" << Number[15] << "|" << endl;
cout << "-+-+-+-+-+-+-" << endl;
bool bValidMove;
do {
int randNumber = rand() % 41 + 10;
bValidMove = true;
if(randNumber == Number[0] && Number[0] !='X'){
Number[0] = 'X';
}
if(randNumber == Number[1] && Number[1] !='X'){
Number[1] = 'X';
}
if(randNumber == Number[2] && Number[2] !='X'){
Number[2] = 'X';
}
if(randNumber == Number[3] && Number[3] !='X'){
Number[3] = 'X';
}
if(randNumber == Number[4] && Number[4] !='X'){
Number[4] = 'X';
}
if(randNumber == Number[5] && Number[5] !='X'){
Number[5] = 'X';
}
if(randNumber == Number[6] && Number[6] !='X'){
Number[6] = 'X';
}
if(randNumber == Number[7] && Number[7] !='X'){
Number[7] = 'X';
}
if(randNumber == Number[8] && Number[8] !='X'){
Number[8] = 'X';
}
if(randNumber == Number[9] && Number[9] !='X'){
Number[9] = 'X';
}
if(randNumber == Number[10] && Number[10] !='X'){
Number[10] = 'X';
}
if(randNumber == Number[11] && Number[11] !='X'){
Number[11] = 'X';
}
if(randNumber == Number[1] && Number[1] !='X'){
Number[1] = 'X';
}
if(randNumber == Number[12] && Number[12] !='X'){
Number[12] = 'X';
}
if(randNumber == Number[12] && Number[12] !='X'){
Number[12] = 'X';
}
if(randNumber == Number[13] && Number[13] !='X'){
Number[13] = 'X';
}
if(randNumber == Number[14] && Number[14] !='X'){
Number[14] = 'X';
}
if(randNumber == Number[15] && Number[15] !='X'){
Number[15] = 'X';
}
}
while(!bValidMove);
if(Number[1] == Number[0] && Number[2] == Number[0] && Number[3] == Number[0]) {
GameOverWin = true;
}
if(Number[4] == Number[0] && Number[8] == Number[0] && Number[12] == Number[0]) {
GameOverWin = true;
}
if(Number[7] == Number[3] && Number[11] == Number[3] && Number[15] == Number[3]) {
GameOverWin = true;
}
if(Number[13] == Number[12] && Number[14] == Number[12] && Number[15] == Number[12]) {
GameOverWin = true;
}
if(Number[5] == Number[1] && Number[9] == Number[1] && Number[13] == Number[1]) {
GameOverWin = true;
}
if(Number[1] == Number[0] && Number[2] == Number[0] && Number[3] == Number[0]) {
GameOverWin = true;
}
if(Number[6] == Number[2] && Number[10] == Number[2] && Number[14] == Number[2]) {
GameOverWin = true;
}
if(Number[5] == Number[4] && Number[6] == Number[4] && Number[7] == Number[4]) {
GameOverWin = true;
}
if(Number[9] == Number[8] && Number[10] == Number[8] && Number[11] == Number[8]) {
GameOverWin = true;
}
if(Number[12] == Number[3] && Number[6] == Number[3] && Number[9] == Number[3]) {
GameOverWin = true;
}
if(Number[5] == Number[0] && Number[10] == Number[0] && Number[15] == Number[0]) {
GameOverWin = true;
}
if(GameOver)
{
cout << "-+-+-+-+-+-+-" << endl;
cout << "|" << Number[0] << "|" << Number[1] << "|" << Number[2] << "|" << Number[3] << "|" << endl;
cout << "-+-+-+-+-+-+-" << endl;
cout << "|" << Number[4] << "|" << Number[5] << "|" << Number[6] << "|" << Number[7] << "|" << endl;
cout << "-+-+-+-+-+-+-" << endl;
cout << "|" << Number[8] << "|" << Number[9] << "|" << Number[10] << "|" << Number[11] << "|" << endl;
cout << "-+-+-+-+-+-+-" << endl;
cout << "|" << Number[12] << "|" << Number[13] << "|" << Number[14] << "|" << Number[15] << "|" << endl;
cout << "-+-+-+-+-+-+-" << endl;
cout << "BINGO!, you won congrat" << endl;
}
cin.get();
cin.get();
}while(!GameOver);
--k;
}
cin.get();
cin.get();
return 0;
}