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

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

相关推荐
消失的旧时光-194310 分钟前
c++ 的标准库 --- std::
c++·jni
The_cute_cat15 分钟前
JavaScript的初步学习
开发语言·javascript·学习
GiraKoo28 分钟前
【GiraKoo】C++11的新特性
c++·后端
不午睡的探索者31 分钟前
告别性能瓶颈!Python 量化工程师,进击 C++ 高性能量化交易的“必修课”!
c++·github
OpenC++31 分钟前
【C++】观察者模式
c++·观察者模式·设计模式
Naiva36 分钟前
【小技巧】Python + PyCharm 小智AI配置MCP接入点使用说明(内测)( PyInstaller打包成 .exe 可执行文件)
开发语言·python·pycharm
老歌老听老掉牙41 分钟前
粒子群优化算法实现与多维函数优化应用
c++·pso·粒子群算法
梦子要转行1 小时前
matlab/Simulink-全套50个汽车性能建模与仿真源码模型9
开发语言·matlab·汽车
myloveasuka1 小时前
信号操作集函数
linux·运维·服务器·c语言·c++·vscode
北方有星辰zz1 小时前
数据结构:栈
java·开发语言·数据结构