how to use _getch();
but instead of the program stopping at _getch();
to keep going but if you input a key while the rest of the program is executing, give the input to getch
i am sorry about the format but i cant fix it... already tried, but it went in without tabs
mod-edit: formatting
but instead of the program stopping at _getch();
to keep going but if you input a key while the rest of the program is executing, give the input to getch
C++:
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <string>
#include <cstring>
#include <Windows.h>
#include <conio.h>
using namespace std;
int ran, z, i = 20, h, it = 5;
string enemy = "<";
string space[20] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ",
" ", " ", " ", " ", " ", " ",
" ", " "};
char key = ' ';
string you = ":)";
int main(){
srand(time(NULL));
while (1){
i = 20;
system("cls");
ran = rand() % 10;
z = ran;
h = ran;
while (ran > 1) {
ran--;
cout << endl;
}
while (i > 0){
key = _getch();
system("cls");
z = h;
while (z > 0){
z--;
cout << endl;
}
i--;
cout << space[i] << enemy;
if (key != ' '){
if (key == 'w'){
while (it > 1){
it--;
cout << endl;
z++;
cout << you;
}
}
else if (key == 's'){
while (it < 10){
it++;
cout << endl;
z--;
cout << you;
}
}
}
}
}
system("PAUSE");
return 0;
}
i am sorry about the format but i cant fix it... already tried, but it went in without tabs
mod-edit: formatting