没错误判定,有些许卡顿
#include <bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<iostream>
#include<bitset>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
deque<string> maps;
deque<char> keys;
int main() {
int n=0;
int i=3;
int min,max;
min = 1;
max = 4;
int combo=0;
int len=20,speed=10;
while (1) {
if(i%3!=0) maps.push_front(" | | | | | ");
else {
int a = rand() % (max - min + 1) + min;
if(a == 1) {
maps.push_front(" | ■| | | | ");
keys.push_back('D');
}
if(a == 2) {
maps.push_front(" | | ■| | | ");
keys.push_back('F');
}
if(a == 3) {
maps.push_front(" | | | ■| | ");
keys.push_back('J');
}
if(a == 4) {
maps.push_front(" | | | | ■|");
keys.push_back('K');
}
}
i++;
system("cls");
if(i>len) {
for(int a=0; a<maps.size(); a++) {
cout<<maps[a]<<endl;
}
cout<<" | □| □| □| □|"<<" Combo: "<<combo<<endl;
cout<<" | D | F | J | K |"<<endl;
cout<<" -----------------"<<endl;
if(maps.size()>=len)maps.pop_back();
Sleep(speed);
if(i%3==0) {
while (KEY_DOWN(keys[n]) == false) {
Sleep(0.1);
}
combo++;
while (KEY_DOWN(keys[n]) == true) {
Sleep(0.1);
}
n++;
}
}
}
}