C++小玩具1

好耶是新系列

cpp 复制代码
#include<windows.h>
#include<bits/stdc++.h>
using namespace std;
POINT p;
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
HWND h=GetForegroundWindow();
CONSOLE_FONT_INFO consoleCurrentFont;
int X,Y,jg;
bool f;
void G(int x,int y){
	COORD pos={x,y};
	HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOut,pos);
	return;
}
void S(int ForgC, int BackC) {
	WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}
void HC(){
	CONSOLE_CURSOR_INFO cur={1,0};
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cur);
}
void SC(){
	CONSOLE_CURSOR_INFO cur={1,1};
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cur);
}
int main(){
	system("mode con cols=50 lines=20");
	HC();
	srand(time(0));
	HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
	DWORD mode;
	GetConsoleMode(hStdin, &mode);
	mode &= ~ENABLE_QUICK_EDIT_MODE;
	SetConsoleMode(hStdin, mode);
	X=rand()%47+2;Y=rand()%17+2;
	while(1){
		POINT p;
		GetCursorPos(&p);
		ScreenToClient(h,&p);
		GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
		int x=p.x/=consoleCurrentFont.dwFontSize.X;
		int y=p.y/=consoleCurrentFont.dwFontSize.Y;
		if(x>1&&x<50&&y>1&&y<20&&x!=X&&y!=Y) {  
			G(x,y);
			cout<<".";
		}
		if((x==X||x==X+1)&&y==Y){
			f=true;	
		}else f=false;
		if(GetAsyncKeyState(VK_LBUTTON)){
			if((x==X||x==X+1)&&y==Y){
				G(X,Y);
				cout<<"  ";
				X=rand()%47+2;Y=rand()%17+2;
			}
		}
		Sleep(10); 
		G(x,y);
		cout<<" ";
		G(X,Y);
		if(f)S(9,0);
		else S(14,0);
		cout<<"按"; 
		S(15,0);
		if(jg!=0)jg--;
	}
	return 0;
}

你管他是啥,"好用就行"

相关推荐
可靠的仙人掌3 分钟前
SAC(Soft Actor-Critic)算法底座
开发语言·算法·php
学逆向的25 分钟前
汇编——数据存储模式
开发语言·汇编·网络安全
geovindu35 分钟前
CSharp: Prototype Pattern
开发语言·后端·设计模式·.net·原型模式·创建型模式
王老师青少年编程41 分钟前
csp信奥赛C++高频考点专项训练:【二分答案】案例2:木材加工
c++·二分答案·csp·高频考点·信奥赛·木材加工
天天进步20151 小时前
Python全栈项目--校园食堂点餐与推荐系统
开发语言·python
aaPIXa6221 小时前
C++模板元编程:编译期计算Fibonacci数列
java·开发语言·c++
eybk2 小时前
写一个可以编制pdf文件的python程序
开发语言·python·pdf
Augustzero2 小时前
`co_await` 按下暂停键之后:从零看懂 C++20 协程
c++·后端
cui_ruicheng2 小时前
Python从入门到实战(八):封装、多态与抽象类
开发语言·python
apihz2 小时前
台风实时与历史详情查询免费 API 接口完整教程
android·开发语言·tcp/ip·dubbo·台风·天气预报