vendredi 13 mars 2020

How can I fix this quit loop?

I am trying to add a quit input so that I can end my game but it isn't working at all and I don't know why. I can used the quit loop before but that was when I involved ch = _getch(); and switch (ch) which I used for movement in my tutorial but now I just want to involve thw quit loop by itself

#include<Windows.h>
#include<iostream>
#include<vector>
using namespace std;


int main()
{
// specify default value to fill the vector elements
int mapSize = 0;
int row = 0;
int column = 0;
int x = row = 0;
int y = column = 0;
int horizontal = 0;
int vertical = 0;
int player = horizontal && vertical;

cout << "Enter the size of board => ";
cin >> mapSize;

vector< vector<char> > board(mapSize, vector<char>(mapSize, 'e'));
for (int i = 0; i < mapSize; i++) {
    for (int j = 0; j < mapSize; j++) {
        cout << board[i][j] << " ";
    }
    cout << endl;
}

char ch = 0;
cout << "Press Q to quit\n";
do
{

} while (ch != 'Q' && ch != 'q');

    }

Aucun commentaire:

Enregistrer un commentaire