[Games] 4K Freaser -demo

version demo0.3

#include<bits/stdc++.h>
#include<conio.h>
#include<windows.h>
using namespace std;
int a[11][5],ct,et,st=0;

void csct(int x,int color){
	if(x!=0){
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color);
		cout<<"  ";
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0x0F);
	}
	else{
		cout<<"  ";
	}
}

void sc(){
	system("cls");
	for(int i=1;i<=10;++i){
		for(int j=1;j<=4;++j){
			csct(a[i][j],0xB0);
//			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<"X C N M"<<endl;
}

void down(){
	for(int i=10;i>=2;--i){
		for(int j=1;j<=4;++j){
			a[i][j]=a[i-1][j];
		}
	}
	int x=rand()%4+1;
	for(int i=1;i<=4;++i){
		if(i==x){
			a[1][i]=1;
		}
		else{
			a[1][i]=0;
		}
	}
	sc();
}

bool check(int p){
	if(a[10][p]==1){
		down();
		return true;
	}
	else{
		down();
		return false;
	}
}

int main(){
	srand(time(NULL));
	for(int i=1;i<=10;++i){
		down();
	}
	sc();
	while(1){
		if(kbhit()){
			if(st==0){
				st=time(NULL);
			}
			int a=getch(),m=0;
			if(a==48){
			 	break;
			}
			else if(a==120){
				m=1;
			}
			else if(a==99){
				m=2;
			}
			else if(a==110){
				m=3;
			}
			else if(a==109){
				m=4;
			}
			else{
				continue; 
			}
			if(check(m)==false){
				et++;
				cout<<m<<" error. ("<<et<<")"<<endl;
			}
			else{
				ct++;
			}
			cout<<"Correct rate ";
			printf("%.3f\n",(double)ct*100/(et+ct));
			cout<<"Speed ";
			printf("%.3f clicks/s\n",((double)ct/(time(NULL)-st)));
			cout<<"%"<<endl;
		}
	}
}
posted @ 2024-02-23 20:26  HaneDaniko  阅读(9)  评论(0编辑  收藏  举报