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

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

相关推荐
charlie11451419113 分钟前
Android开发——初步了解AndroidManifest.xml
android·xml·开发语言·学习·安卓·安全架构
Edward.W26 分钟前
用 Go + HTML 实现 OpenHarmony 投屏(hdckit-go + WebSocket + Canvas 实战)
开发语言·后端·golang
钱彬 (Qian Bin)30 分钟前
一文掌握工业缺陷检测项目实战(Pytorch算法训练、部署、C++ DLL制作、Qt集成)
c++·pytorch·python·qt·实战·工业缺陷检测·faster rcnn
努力努力再努力wz38 分钟前
【c++进阶系列】:万字详解AVL树(附源码实现)
java·运维·开发语言·c++·redis
一点都不方女士1 小时前
《无畏契约》游戏报错“缺少DirectX”?5种解决方案(附DirectX修复工具)
windows·游戏·microsoft·动态链接库·directx·运行库
小张成长计划..1 小时前
C++基础知识
c++
CHANG_THE_WORLD1 小时前
C++并发编程指南 std::promise 介绍与使用
java·开发语言·c++·promise
egoist20231 小时前
[linux仓库]性能加速的隐形引擎:深度解析Linux文件IO中的缓冲区奥秘
linux·运维·开发语言·缓存·缓冲区
Dear.爬虫1 小时前
Golang的协程调度器原理
开发语言·后端·golang
小菜全2 小时前
使用UniApp实现下拉框和表格组件页面
开发语言·前端·javascript·elementui·前端框架·html