I’m trying to write a program that makes the you have to press the 'A' key when the X moves to the middle. I've managed to get the X to move, but I don't know how to make it check if you pressed 'A' at the write time, and also recognize if you press it at the wrong time or you don't press it at all. How would I do that? (The program below is just a test program)
TL;DR how would I make it so you have to press the 'A' key when 'X' is in the center of the vector?
Sorry if this is a dumb question.
#include <iostream>
#include <vector>
#include <thread>
#include <chrono>
int main() {
std::vector <char> hi = {'X','O','O','O','O','O','O','O'};
for (int i = 0; i < hi.size() - 1; i++) {
for (int i = 0; i < hi.size() - 1; i++) {
std::cout << hi[i];
}
char temp = hi[i + 1];
hi[i + 1] = hi[i];
hi[i] = temp;
std::this_thread::sleep_for (std::chrono::seconds(1));
std::cout << std::endl << "\E[2J\E[2H";
}
}