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

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

相关推荐
2401_858286113 分钟前
OS15.【Linux】gdb调试器的简单使用
linux·运维·服务器·开发语言·gdb
牛马baby4 分钟前
MATLAB下载安装教程(附安装包)2025最新版(MATLAB R2024b)
开发语言·matlab
GiraKoo8 分钟前
【GiraKoo】C++17的新特性
c++
Rockson13 分钟前
C++如何查询实时贵金属行情
c++·api
shenyan~13 分钟前
关于 c、c#、c++ 三者区别
开发语言·c++
Ashlee_code24 分钟前
什么是Web3?金融解决方案
开发语言·金融·架构·eclipse·web3·区块链·php
Evand J38 分钟前
【MATLAB例程】AOA与TDOA混合定位例程,适用于三维环境、4个锚点的情况,附下载链接
开发语言·matlab
机器视觉知识推荐、就业指导38 分钟前
Qt 与Halcon联合开发八: 结合Qt与Halcon实现海康相机采图显示(附源码)
开发语言·数码相机·qt
mit6.8241 小时前
[vroom] docs | 输入与问题定义 | 任务与运输工具 | json
c++·自动驾驶
Heartoxx1 小时前
c语言-指针与一维数组
c语言·开发语言·算法