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;
}

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

相关推荐
哆啦A梦15882 分钟前
在golang中如何将已安装的依赖降级处理,比如:将 go-ansible/[email protected] 更换为 go-ansible/@v1.1.7
开发语言·golang·ansible
Teln_小凯15 分钟前
Python读取阿里法拍网的html+解决登录cookie
开发语言·python·html
Tiger Z20 分钟前
R 语言科研绘图第 55 期 --- 网络图-聚类
开发语言·r语言·贴图
love530love40 分钟前
【笔记】旧版MSYS2 环境中 Rust 升级问题及解决过程
开发语言·人工智能·windows·笔记·python·rust·virtualenv
扣丁梦想家1 小时前
✅ 常用 Java HTTP 客户端汇总及使用示例
java·开发语言·http
Code_流苏1 小时前
C++课设:智能优惠快餐点餐系统
开发语言·c++·课设·期末大作业·快餐点餐系统·智能优惠算法
越城1 小时前
深入解析C++引用:从别名机制到函数特性实践
c++
sss191s2 小时前
Java 集合面试题 PDF 及常见考点解析与备考指南
java·开发语言·pdf
老刘忙Giser2 小时前
c# List<string>.Add(s) 报错:UnsupportedOperationException
开发语言·c#
itwlz2 小时前
vite配置@别名,以及如何让IDE智能提示路经
开发语言·前端·javascript