『整活』大家的桌宠二创
Luna_From_Starry
·
·
休闲·娱乐
左脚踩右脚上天型
#include<iostream>
//#include <graphics.h>
#include<windows.h>
#include<conio.h>
#include<vector>
using namespace std;
HWND hWnd=GetForegroundWindow();
int srcw=GetSystemMetrics(SM_CXSCREEN);
int srch=GetSystemMetrics(SM_CYSCREEN);
bool key[100];//WSAD
POINT mousepos;
void getkey(){
key[0]=(GetAsyncKeyState('W')|GetAsyncKeyState(VK_UP))&0x8000;
key[1]=(GetAsyncKeyState('S')|GetAsyncKeyState(VK_DOWN))&0x8000;
key[2]=(GetAsyncKeyState('A')|GetAsyncKeyState(VK_LEFT))&0x8000;
key[3]=(GetAsyncKeyState('D')|GetAsyncKeyState(VK_RIGHT))&0x8000;
key[4]=(GetAsyncKeyState('O'))&0x8000;
key[5]=(GetAsyncKeyState('H'))&0x8000;
key[6]=(GetAsyncKeyState('F'))&0x8000;
key[7]=(GetAsyncKeyState('P'))&0x8000;
key[8]=(GetAsyncKeyState('S'))&0x8000;
key[9]=(GetAsyncKeyState(' '))&0x8000;
key[10]=(GetAsyncKeyState(VK_SHIFT))&0x8000;
key[11]=(GetAsyncKeyState(VK_CONTROL))&0x8000;
key[12]=(GetAsyncKeyState(VK_MENU))&0x8000;
key[13]=(GetAsyncKeyState('K'))&0x8000;
}
bool inline inside(int x,int y,int w,int h,int mx,int my){
return mx>=x&&mx<x+w&&my>=y&&my<y+h;
}
bool inline inside(int x,int l,int r){
return x>l&&x<r;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam){
vector<HWND>* data=reinterpret_cast<vector<HWND>*>(lParam);
data->push_back(hwnd);
return TRUE;
}
vector<RECT> windowsRect;
vector<HWND> hwnds;
void getWindowsRect(){
windowsRect.clear();
//static vector<HWND> hwnds;
hwnds.clear();RECT rect;
EnumWindows(EnumWindowsProc,(LPARAM)&hwnds);
for(int i=0; i<hwnds.size(); i++) {
HWND hwnd=hwnds[i];
GetWindowRect(hwnd,&rect);
char buf[256]={0};
GetWindowText(hwnd,buf,sizeof(buf));
LONG style=GetWindowLong(hwnd,GWL_STYLE);
LONG exStyle=GetWindowLong(hwnd,GWL_EXSTYLE);
bool isValid=
IsWindowVisible(hwnd)&& // 排除不可见窗口
!IsIconic(hwnd)&& // 排除最小化窗口
(style&WS_VISIBLE)&& // 必须包含可见样式
!(style&WS_MINIMIZE)&& // 排除最小化样式
(rect.right-rect.left>5)&& // 增加宽度阈值
(rect.bottom-rect.top>5)&& // 增加高度阈值
(buf[0]!='\0')&&
(hwnd!=hWnd);
if(isValid) windowsRect.push_back(rect);
}
}
int collideY(int x,int y,int w,int h){
if(y<0) return 0;
if(y+h>srch) return srch-h;
for(auto& r:windowsRect){
if(inside(x,r.left,r.right)||inside(x+w,r.left,r.right)){
if(inside(r.top,y,y+h)){
if(y+h/2>r.top) return r.top;
return r.top-h;
}else if(inside(r.bottom,y,y+h)){
if(y+h/2<r.bottom) return r.bottom-h;
return r.bottom;
}
}
}
return -114514;
}
int collideX(int x,int y,int w,int h){
if(x<0) return 0;
if(x+w>srcw) return srcw-w;
for(auto& r:windowsRect){
if(inside(r.top,y,y+h)||inside(r.bottom,y,y+h)){
if(inside(r.left,x,x+w)) return r.left-w;
else if(inside(r.right,x,x+w)) return r.right;
}
}
return -114514;
}
bool IsMouseOverCloseButton(HWND hwnd) {
// 获取窗口矩形
RECT windowRect;
GetWindowRect(hwnd, &windowRect);
// 获取鼠标位置
POINT mousePos;
GetCursorPos(&mousePos);
// 计算关闭按钮区域(通常在右上角)
RECT closeButtonRect = {
windowRect.right - 20, // 假设关闭按钮宽度为20
windowRect.top,
windowRect.right,
windowRect.top + 20 // 假设关闭按钮高度为20
};
// 检查鼠标是否在关闭按钮区域内
return PtInRect(&closeButtonRect, mousePos);
}
void coutslow(string s){
for(int i = 0; i < s.size(); i++){
cout << s[i];
Sleep(10);
}
}
void help_for_play(int op){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 11);
system("cls");
bool f_ = 0;
if(op){
FILE* fp = fopen("T.txt","w");
f_ = 0;
fprintf(fp,"%d",f_);
// srand(time(0));
int t = rand() % 2;
if(t == 0){
exit(0);
}
}
FILE* fp = fopen("T.txt","r");
fscanf(fp,"%d",&f_);
if(f_ == 0){
cout << "(按空格 + shift)宠物小贴士:\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键1:ctrl + shift + alt + o(这么复杂的原因是防止快捷键重复)\n");
cout << "作用:\n";
cout << "切换皮肤\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键2:ctrl + shift + alt + h\n");
cout << "作用:\n";
cout << "切换成年/幼年\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键3:ctrl + shift + alt + f\n");
cout << "作用:\n";
cout << "让宠物放置方块\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键4:右键");
cout << "作用:\n";
cout << "放置方块\n";
cout << "按ctrl + shift + alt + p跳过\n";
if(op){
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
system("cls");
cout << "ps:如果你以后不想看到这个了,可以按ctrl + shift + alt + s\n";
cout << " 如果你还想看到这个,可以按ctrl + shift + alt + k(一定记住,可能闪退,闪退后再运行就行了)\n";
}
cout << "ps:如果你以后不想看到这个了,可以按ctrl + shift + alt + s\n";
cout << " 如果你还想看到这个,可以按ctrl + shift + alt + k(一定记住,可能闪退,闪退后再运行就行了)\n";
while(1){
getkey();
if(key[11] && key[10] && key[12]){
if(key[7]){
break;
}
if(key[8]){
FILE* fp = fopen("T.txt","w");
f_ = 1;
fprintf(fp,"%d",f_);
break;
}
}
}
if(op){
system("cls");
}
}SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
}
int main(){
help_for_play(0);
// initgraph(0,0,EW_NOCLOSE);
// closegraph();
// while()
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
int op = 60;
float x=1,y=1,sx=0,sy=0,cx=200,cy=200,cyy=0;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
system("cls");
cout << " \n";
cout << " \n";
cout << "Hi~ o(* ̄▽ ̄*)ブ \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
op = 100;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
int now_f = -1, opp = 0, f = 1, fff = 0, sum = 0;
while(1){
if(sum >= 5){
system("cls");
cout << "\n";
cout << "I'm angry! \n";
cout << " (╬▔^▔)╯ \n";
op = 200;
sum = 0;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(opp >= 3){
// now_f = 3;
opp = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " ╥﹏╥ \n";
op = 30;
sum ++;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(y <= 200 && now_f != 1){
now_f = 1;
fff = 1;
system("cls");
cout << "\n";
cout << " \n";
cout << " (._.`) \n";
}else if(fff == 1 && now_f != 2 && y > 200 && y <= 300){
now_f = 2;
fff = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " >﹏< \n";
}else if(now_f == 2 && sy == 0){
// now_f = 3;
opp ++;
if(opp == 1){
system("cls");
cout << "\n";
cout << " \n";
cout << " ⊙﹏⊙ \n";
}
}else if(now_f == -1 && f){
now_f = -1;
f = 0;
system("cls");
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";0 1720
// cout << " \n";1 848.5
// cout << " \n";147 878
// cout << " \n";191 878
// cout << " \n";147 850
// cout << " \n";191 850
cout << " ";
}
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
return 0;
}
// SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 这里);
/*
0 = 黑色 8 = 灰色
1 = 蓝色 9 = 淡蓝色
2 = 绿色 10 = 淡绿色
3 = 湖蓝色 11 = 淡浅绿色
4 = 红色 12 = 淡红色
5 = 紫色 13 = 淡紫色
6 = 黄色 14 = 淡黄色
7 = 白色 15 = 亮白色
*/
僵尸弹跳型
#include<iostream>
//#include <graphics.h>
#include<windows.h>
#include<conio.h>
#include<vector>
using namespace std;
HWND hWnd=GetForegroundWindow();
int srcw=GetSystemMetrics(SM_CXSCREEN);
int srch=GetSystemMetrics(SM_CYSCREEN);
bool key[100];//WSAD
POINT mousepos;
void getkey(){
key[0]=(GetAsyncKeyState('W')|GetAsyncKeyState(VK_UP))&0x8000;
key[1]=(GetAsyncKeyState('S')|GetAsyncKeyState(VK_DOWN))&0x8000;
key[2]=(GetAsyncKeyState('A')|GetAsyncKeyState(VK_LEFT))&0x8000;
key[3]=(GetAsyncKeyState('D')|GetAsyncKeyState(VK_RIGHT))&0x8000;
key[4]=(GetAsyncKeyState('O'))&0x8000;
key[5]=(GetAsyncKeyState('H'))&0x8000;
key[6]=(GetAsyncKeyState('F'))&0x8000;
key[7]=(GetAsyncKeyState('P'))&0x8000;
key[8]=(GetAsyncKeyState('S'))&0x8000;
key[9]=(GetAsyncKeyState(' '))&0x8000;
key[10]=(GetAsyncKeyState(VK_SHIFT))&0x8000;
key[11]=(GetAsyncKeyState(VK_CONTROL))&0x8000;
key[12]=(GetAsyncKeyState(VK_MENU))&0x8000;
key[13]=(GetAsyncKeyState('K'))&0x8000;
}
bool inline inside(int x,int y,int w,int h,int mx,int my){
return mx>=x&&mx<x+w&&my>=y&&my<y+h;
}
bool inline inside(int x,int l,int r){
return x>l&&x<r;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam){
vector<HWND>* data=reinterpret_cast<vector<HWND>*>(lParam);
data->push_back(hwnd);
return TRUE;
}
vector<RECT> windowsRect;
vector<HWND> hwnds;
void getWindowsRect(){
windowsRect.clear();
//static vector<HWND> hwnds;
hwnds.clear();RECT rect;
EnumWindows(EnumWindowsProc,(LPARAM)&hwnds);
for(int i=0; i<hwnds.size(); i++) {
HWND hwnd=hwnds[i];
GetWindowRect(hwnd,&rect);
char buf[256]={0};
GetWindowText(hwnd,buf,sizeof(buf));
LONG style=GetWindowLong(hwnd,GWL_STYLE);
LONG exStyle=GetWindowLong(hwnd,GWL_EXSTYLE);
bool isValid=
IsWindowVisible(hwnd)&& // 排除不可见窗口
!IsIconic(hwnd)&& // 排除最小化窗口
(style&WS_VISIBLE)&& // 必须包含可见样式
!(style&WS_MINIMIZE)&& // 排除最小化样式
(rect.right-rect.left>5)&& // 增加宽度阈值
(rect.bottom-rect.top>5)&& // 增加高度阈值
(buf[0]!='\0')&&
(hwnd!=hWnd);
if(isValid) windowsRect.push_back(rect);
}
}
int collideY(int x,int y,int w,int h){
if(y<0) return 0;
if(y+h>srch) return srch-h;
for(auto& r:windowsRect){
if(inside(x,r.left,r.right)||inside(x+w,r.left,r.right)){
if(inside(r.top,y,y+h)){
if(y+h/2>r.top) return r.top;
return r.top-h;
}else if(inside(r.bottom,y,y+h)){
if(y+h/2<r.bottom) return r.bottom-h;
return r.bottom;
}
}
}
return -114514;
}
int collideX(int x,int y,int w,int h){
if(x<0) return 0;
if(x+w>srcw) return srcw-w;
for(auto& r:windowsRect){
if(inside(r.top,y,y+h)||inside(r.bottom,y,y+h)){
if(inside(r.left,x,x+w)) return r.left-w;
else if(inside(r.right,x,x+w)) return r.right;
}
}
return -114514;
}
bool IsMouseOverCloseButton(HWND hwnd) {
// 获取窗口矩形
RECT windowRect;
GetWindowRect(hwnd, &windowRect);
// 获取鼠标位置
POINT mousePos;
GetCursorPos(&mousePos);
// 计算关闭按钮区域(通常在右上角)
RECT closeButtonRect = {
windowRect.right - 20, // 假设关闭按钮宽度为20
windowRect.top,
windowRect.right,
windowRect.top + 20 // 假设关闭按钮高度为20
};
// 检查鼠标是否在关闭按钮区域内
return PtInRect(&closeButtonRect, mousePos);
}
void coutslow(string s){
for(int i = 0; i < s.size(); i++){
cout << s[i];
Sleep(10);
}
}
void help_for_play(int op){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 11);
system("cls");
bool f_ = 0;
if(op){
FILE* fp = fopen("T.txt","w");
f_ = 0;
fprintf(fp,"%d",f_);
// srand(time(0));
int t = rand() % 2;
if(t == 0){
exit(0);
}
}
FILE* fp = fopen("T.txt","r");
fscanf(fp,"%d",&f_);
if(f_ == 0){
cout << "(按空格 + shift)宠物小贴士:\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键1:ctrl + shift + alt + o(这么复杂的原因是防止快捷键重复)\n");
cout << "作用:\n";
cout << "切换皮肤\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键2:ctrl + shift + alt + h\n");
cout << "作用:\n";
cout << "切换成年/幼年\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键3:ctrl + shift + alt + f\n");
cout << "作用:\n";
cout << "让宠物放置方块\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键4:右键");
cout << "作用:\n";
cout << "放置方块\n";
cout << "按ctrl + shift + alt + p跳过\n";
if(op){
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
system("cls");
cout << "ps:如果你以后不想看到这个了,可以按ctrl + shift + alt + s\n";
cout << " 如果你还想看到这个,可以按ctrl + shift + alt + k(一定记住,可能闪退,闪退后再运行就行了)\n";
}
cout << "ps:如果你以后不想看到这个了,可以按ctrl + shift + alt + s\n";
cout << " 如果你还想看到这个,可以按ctrl + shift + alt + k(一定记住,可能闪退,闪退后再运行就行了)\n";
while(1){
getkey();
if(key[11] && key[10] && key[12]){
if(key[7]){
break;
}
if(key[8]){
FILE* fp = fopen("T.txt","w");
f_ = 1;
fprintf(fp,"%d",f_);
break;
}
}
}
if(op){
system("cls");
}
}SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
}
int main(){
help_for_play(0);
// initgraph(0,0,EW_NOCLOSE);
// closegraph();
// while()
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
int op = 60;
float x=1,y=1,sx=0,sy=0,cx=200,cy=200,cyy=0;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
system("cls");
cout << " \n";
cout << " \n";
cout << "Hi~ o(* ̄▽ ̄*)ブ \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
op = 100;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
int now_f = -1, opp = 0, f = 1, fff = 0, sum = 0;
while(1){
if(sum >= 5){
system("cls");
cout << "\n";
cout << "I'm angry! \n";
cout << " (╬▔^▔)╯ \n";
op = 200;
sum = 0;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(opp >= 3){
// now_f = 3;
opp = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " ╥﹏╥ \n";
op = 30;
sum ++;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(y <= 200 && now_f != 1){
now_f = 1;
fff = 1;
system("cls");
cout << "\n";
cout << " \n";
cout << " (._.`) \n";
}else if(fff == 1 && now_f != 2 && y > 200 && y <= 300){
now_f = 2;
fff = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " >﹏< \n";
}else if(now_f == 2 && sy == 0){
// now_f = 3;
opp ++;
if(opp == 1){
system("cls");
cout << "\n";
cout << " \n";
cout << " ⊙﹏⊙ \n";
}
}else if(now_f == -1 && f){
now_f = -1;
f = 0;
system("cls");
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";0 1720
// cout << " \n";1 848.5
// cout << " \n";147 878
// cout << " \n";191 878
// cout << " \n";147 850
// cout << " \n";191 850
cout << " ";
}
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
x += 1;
y -= 10;
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
return 0;
}
// SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 这里);
/*
0 = 黑色 8 = 灰色
1 = 蓝色 9 = 淡蓝色
2 = 绿色 10 = 淡绿色
3 = 湖蓝色 11 = 淡浅绿色
4 = 红色 12 = 淡红色
5 = 紫色 13 = 淡紫色
6 = 黄色 14 = 淡黄色
7 = 白色 15 = 亮白色
*/
游走型
#include<iostream>
//#include <graphics.h>
#include<windows.h>
#include<conio.h>
#include<vector>
using namespace std;
HWND hWnd=GetForegroundWindow();
int srcw=GetSystemMetrics(SM_CXSCREEN);
int srch=GetSystemMetrics(SM_CYSCREEN);
bool key[100];//WSAD
POINT mousepos;
void getkey(){
key[0]=(GetAsyncKeyState('W')|GetAsyncKeyState(VK_UP))&0x8000;
key[1]=(GetAsyncKeyState('S')|GetAsyncKeyState(VK_DOWN))&0x8000;
key[2]=(GetAsyncKeyState('A')|GetAsyncKeyState(VK_LEFT))&0x8000;
key[3]=(GetAsyncKeyState('D')|GetAsyncKeyState(VK_RIGHT))&0x8000;
key[4]=(GetAsyncKeyState('O'))&0x8000;
key[5]=(GetAsyncKeyState('H'))&0x8000;
key[6]=(GetAsyncKeyState('F'))&0x8000;
key[7]=(GetAsyncKeyState('P'))&0x8000;
key[8]=(GetAsyncKeyState('S'))&0x8000;
key[9]=(GetAsyncKeyState(' '))&0x8000;
key[10]=(GetAsyncKeyState(VK_SHIFT))&0x8000;
key[11]=(GetAsyncKeyState(VK_CONTROL))&0x8000;
key[12]=(GetAsyncKeyState(VK_MENU))&0x8000;
key[13]=(GetAsyncKeyState('K'))&0x8000;
}
bool inline inside(int x,int y,int w,int h,int mx,int my){
return mx>=x&&mx<x+w&&my>=y&&my<y+h;
}
bool inline inside(int x,int l,int r){
return x>l&&x<r;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam){
vector<HWND>* data=reinterpret_cast<vector<HWND>*>(lParam);
data->push_back(hwnd);
return TRUE;
}
vector<RECT> windowsRect;
vector<HWND> hwnds;
void getWindowsRect(){
windowsRect.clear();
//static vector<HWND> hwnds;
hwnds.clear();RECT rect;
EnumWindows(EnumWindowsProc,(LPARAM)&hwnds);
for(int i=0; i<hwnds.size(); i++) {
HWND hwnd=hwnds[i];
GetWindowRect(hwnd,&rect);
char buf[256]={0};
GetWindowText(hwnd,buf,sizeof(buf));
LONG style=GetWindowLong(hwnd,GWL_STYLE);
LONG exStyle=GetWindowLong(hwnd,GWL_EXSTYLE);
bool isValid=
IsWindowVisible(hwnd)&& // 排除不可见窗口
!IsIconic(hwnd)&& // 排除最小化窗口
(style&WS_VISIBLE)&& // 必须包含可见样式
!(style&WS_MINIMIZE)&& // 排除最小化样式
(rect.right-rect.left>5)&& // 增加宽度阈值
(rect.bottom-rect.top>5)&& // 增加高度阈值
(buf[0]!='\0')&&
(hwnd!=hWnd);
if(isValid) windowsRect.push_back(rect);
}
}
int collideY(int x,int y,int w,int h){
if(y<0) return 0;
if(y+h>srch) return srch-h;
for(auto& r:windowsRect){
if(inside(x,r.left,r.right)||inside(x+w,r.left,r.right)){
if(inside(r.top,y,y+h)){
if(y+h/2>r.top) return r.top;
return r.top-h;
}else if(inside(r.bottom,y,y+h)){
if(y+h/2<r.bottom) return r.bottom-h;
return r.bottom;
}
}
}
return -114514;
}
int collideX(int x,int y,int w,int h){
if(x<0) return 0;
if(x+w>srcw) return srcw-w;
for(auto& r:windowsRect){
if(inside(r.top,y,y+h)||inside(r.bottom,y,y+h)){
if(inside(r.left,x,x+w)) return r.left-w;
else if(inside(r.right,x,x+w)) return r.right;
}
}
return -114514;
}
bool IsMouseOverCloseButton(HWND hwnd) {
// 获取窗口矩形
RECT windowRect;
GetWindowRect(hwnd, &windowRect);
// 获取鼠标位置
POINT mousePos;
GetCursorPos(&mousePos);
// 计算关闭按钮区域(通常在右上角)
RECT closeButtonRect = {
windowRect.right - 20, // 假设关闭按钮宽度为20
windowRect.top,
windowRect.right,
windowRect.top + 20 // 假设关闭按钮高度为20
};
// 检查鼠标是否在关闭按钮区域内
return PtInRect(&closeButtonRect, mousePos);
}
void coutslow(string s){
for(int i = 0; i < s.size(); i++){
cout << s[i];
Sleep(10);
}
}
void help_for_play(int op){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 11);
system("cls");
bool f_ = 0;
if(op){
FILE* fp = fopen("T.txt","w");
f_ = 0;
fprintf(fp,"%d",f_);
// srand(time(0));
int t = rand() % 2;
if(t == 0){
exit(0);
}
}
FILE* fp = fopen("T.txt","r");
fscanf(fp,"%d",&f_);
if(f_ == 0){
cout << "(按空格 + shift)宠物小贴士:\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键1:ctrl + shift + alt + o(这么复杂的原因是防止快捷键重复)\n");
cout << "作用:\n";
cout << "切换皮肤\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键2:ctrl + shift + alt + h\n");
cout << "作用:\n";
cout << "切换成年/幼年\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键3:ctrl + shift + alt + f\n");
cout << "作用:\n";
cout << "让宠物放置方块\n";
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
if(op){
system("cls");
}
coutslow("按键4:右键");
cout << "作用:\n";
cout << "放置方块\n";
cout << "按ctrl + shift + alt + p跳过\n";
if(op){
while(1){
getkey();
if(key[9] && key[10]){
break;
}
}
system("cls");
cout << "ps:如果你以后不想看到这个了,可以按ctrl + shift + alt + s\n";
cout << " 如果你还想看到这个,可以按ctrl + shift + alt + k(一定记住,可能闪退,闪退后再运行就行了)\n";
}
cout << "ps:如果你以后不想看到这个了,可以按ctrl + shift + alt + s\n";
cout << " 如果你还想看到这个,可以按ctrl + shift + alt + k(一定记住,可能闪退,闪退后再运行就行了)\n";
while(1){
getkey();
if(key[11] && key[10] && key[12]){
if(key[7]){
break;
}
if(key[8]){
FILE* fp = fopen("T.txt","w");
f_ = 1;
fprintf(fp,"%d",f_);
break;
}
}
}
if(op){
system("cls");
}
}SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
}
int main(){
help_for_play(0);
// initgraph(0,0,EW_NOCLOSE);
// closegraph();
// while()
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
int op = 60;
float x=1,y=1,sx=0,sy=0,cx=200,cy=200,cyy=0;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
system("cls");
cout << " \n";
cout << " \n";
cout << "Hi~ o(* ̄▽ ̄*)ブ \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
op = 100;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
int now_f = -1, opp = 0, f = 1, fff = 0, sum = 0;
while(1){
if(sum >= 5){
system("cls");
cout << "\n";
cout << "I'm angry! \n";
cout << " (╬▔^▔)╯ \n";
op = 200;
sum = 0;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(opp >= 3){
// now_f = 3;
opp = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " ╥﹏╥ \n";
op = 30;
sum ++;
while(op --){
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(y <= 200 && now_f != 1){
now_f = 1;
fff = 1;
system("cls");
cout << "\n";
cout << " \n";
cout << " (._.`) \n";
}else if(fff == 1 && now_f != 2 && y > 200 && y <= 300){
now_f = 2;
fff = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " >﹏< \n";
}else if(now_f == 2 && sy == 0){
// now_f = 3;
opp ++;
if(opp == 1){
system("cls");
cout << "\n";
cout << " \n";
cout << " ⊙﹏⊙ \n";
}
}else if(now_f == -1 && f){
now_f = -1;
f = 0;
system("cls");
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";0 1720
// cout << " \n";1 848.5
// cout << " \n";147 878
// cout << " \n";191 878
// cout << " \n";147 850
// cout << " \n";191 850
cout << " ";
}
getkey();
if(key[11] && key[10] && key[12]){
if(key[13]){
help_for_play(1);
break;
}
}
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
x += 1;
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
return 0;
}
// SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 这里);
/*
0 = 黑色 8 = 灰色
1 = 蓝色 9 = 淡蓝色
2 = 绿色 10 = 淡绿色
3 = 湖蓝色 11 = 淡浅绿色
4 = 红色 12 = 淡红色
5 = 紫色 13 = 淡紫色
6 = 黄色 14 = 淡黄色
7 = 白色 15 = 亮白色
*/
闪电侠型
#include<iostream>
#include<windows.h>
#include<vector>
using namespace std;
HWND hWnd=GetForegroundWindow();
int srcw=GetSystemMetrics(SM_CXSCREEN);
int srch=GetSystemMetrics(SM_CYSCREEN);
bool key[4];//WSAD
POINT mousepos;
void getkey(){
key[0]=(GetAsyncKeyState('W')|GetAsyncKeyState(VK_UP))&0x8000;
key[1]=(GetAsyncKeyState('S')|GetAsyncKeyState(VK_DOWN))&0x8000;
key[2]=(GetAsyncKeyState('A')|GetAsyncKeyState(VK_LEFT))&0x8000;
key[3]=(GetAsyncKeyState('D')|GetAsyncKeyState(VK_RIGHT))&0x8000;
}
bool inline inside(int x,int y,int w,int h,int mx,int my){
return mx>=x&&mx<x+w&&my>=y&&my<y+h;
}
bool inline inside(int x,int l,int r){
return x>l&&x<r;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam){
vector<HWND>* data=reinterpret_cast<vector<HWND>*>(lParam);
data->push_back(hwnd);
return TRUE;
}
vector<RECT> windowsRect;
vector<HWND> hwnds;
void getWindowsRect(){
windowsRect.clear();
//static vector<HWND> hwnds;
hwnds.clear();RECT rect;
EnumWindows(EnumWindowsProc,(LPARAM)&hwnds);
for(int i=0; i<hwnds.size(); i++) {
HWND hwnd=hwnds[i];
GetWindowRect(hwnd,&rect);
char buf[256]={0};
GetWindowText(hwnd,buf,sizeof(buf));
LONG style=GetWindowLong(hwnd,GWL_STYLE);
LONG exStyle=GetWindowLong(hwnd,GWL_EXSTYLE);
bool isValid=
IsWindowVisible(hwnd)&& // 排除不可见窗口
!IsIconic(hwnd)&& // 排除最小化窗口
(style&WS_VISIBLE)&& // 必须包含可见样式
!(style&WS_MINIMIZE)&& // 排除最小化样式
(rect.right-rect.left>5)&& // 增加宽度阈值
(rect.bottom-rect.top>5)&& // 增加高度阈值
(buf[0]!='\0')&&
(hwnd!=hWnd);
if(isValid) windowsRect.push_back(rect);
}
}
int collideY(int x,int y,int w,int h){
if(y<0) return 0;
if(y+h>srch) return srch-h;
for(auto& r:windowsRect){
if(inside(x,r.left,r.right)||inside(x+w,r.left,r.right)){
if(inside(r.top,y,y+h)){
if(y+h/2>r.top) return r.top;
return r.top-h;
}else if(inside(r.bottom,y,y+h)){
if(y+h/2<r.bottom) return r.bottom-h;
return r.bottom;
}
}
}
return -114514;
}
int collideX(int x,int y,int w,int h){
if(x<0) return 0;
if(x+w>srcw) return srcw-w;
for(auto& r:windowsRect){
if(inside(r.top,y,y+h)||inside(r.bottom,y,y+h)){
if(inside(r.left,x,x+w)) return r.left-w;
else if(inside(r.right,x,x+w)) return r.right;
}
}
return -114514;
}
bool IsMouseOverCloseButton(HWND hwnd) {
// 获取窗口矩形
RECT windowRect;
GetWindowRect(hwnd, &windowRect);
// 获取鼠标位置
POINT mousePos;
GetCursorPos(&mousePos);
// 计算关闭按钮区域(通常在右上角)
RECT closeButtonRect = {
windowRect.right - 20, // 假设关闭按钮宽度为20
windowRect.top,
windowRect.right,
windowRect.top + 20 // 假设关闭按钮高度为20
};
// 检查鼠标是否在关闭按钮区域内
return PtInRect(&closeButtonRect, mousePos);
}
int main(){
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
int op = 60;
float x=1,y=1,sx=0,sy=0,cx=200,cy=200,cyy=0;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
system("cls");
cout << " \n";
cout << " \n";
cout << "Hi~ o(* ̄▽ ̄*)ブ \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
op = 100;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
int now_f = -1, opp = 0, f = 1, fff = 0, sum = 0;
while(1){
x ++;
y --;
if(sum >= 5){
system("cls");
cout << "\n";
cout << "I'm angry! \n";
cout << " (╬▔^▔)╯ \n";
op = 200;
sum = 0;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(opp >= 3){
// now_f = 3;
opp = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " ╥﹏╥ \n";
op = 30;
sum ++;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(y <= 200 && now_f != 1){
now_f = 1;
fff = 1;
system("cls");
cout << "\n";
cout << " \n";
cout << " (._.`) \n";
}else if(fff == 1 && now_f != 2 && y > 200 && y <= 300){
now_f = 2;
fff = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " >﹏< \n";
}else if(now_f == 2 && sy == 0){
// now_f = 3;
opp ++;
if(opp == 1){
system("cls");
cout << "\n";
cout << " \n";
cout << " ⊙﹏⊙ \n";
}
}else if(now_f == -1 && f){
now_f = -1;
f = 0;
system("cls");
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";0 1720
// cout << " \n";1 848.5
// cout << " \n";147 878
// cout << " \n";191 878
// cout << " \n";147 850
// cout << " \n";191 850
cout << " ";
}
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
// Sleep(20);
}
return 0;
}
五彩斑斓型
#include<iostream>
#include<windows.h>
#include<vector>
using namespace std;
HWND hWnd=GetForegroundWindow();
int srcw=GetSystemMetrics(SM_CXSCREEN);
int srch=GetSystemMetrics(SM_CYSCREEN);
bool key[4];//WSAD
POINT mousepos;
void getkey(){
key[0]=(GetAsyncKeyState('W')|GetAsyncKeyState(VK_UP))&0x8000;
key[1]=(GetAsyncKeyState('S')|GetAsyncKeyState(VK_DOWN))&0x8000;
key[2]=(GetAsyncKeyState('A')|GetAsyncKeyState(VK_LEFT))&0x8000;
key[3]=(GetAsyncKeyState('D')|GetAsyncKeyState(VK_RIGHT))&0x8000;
}
bool inline inside(int x,int y,int w,int h,int mx,int my){
return mx>=x&&mx<x+w&&my>=y&&my<y+h;
}
bool inline inside(int x,int l,int r){
return x>l&&x<r;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam){
vector<HWND>* data=reinterpret_cast<vector<HWND>*>(lParam);
data->push_back(hwnd);
return TRUE;
}
vector<RECT> windowsRect;
vector<HWND> hwnds;
void getWindowsRect(){
windowsRect.clear();
//static vector<HWND> hwnds;
hwnds.clear();RECT rect;
EnumWindows(EnumWindowsProc,(LPARAM)&hwnds);
for(int i=0; i<hwnds.size(); i++) {
HWND hwnd=hwnds[i];
GetWindowRect(hwnd,&rect);
char buf[256]={0};
GetWindowText(hwnd,buf,sizeof(buf));
LONG style=GetWindowLong(hwnd,GWL_STYLE);
LONG exStyle=GetWindowLong(hwnd,GWL_EXSTYLE);
bool isValid=
IsWindowVisible(hwnd)&& // 排除不可见窗口
!IsIconic(hwnd)&& // 排除最小化窗口
(style&WS_VISIBLE)&& // 必须包含可见样式
!(style&WS_MINIMIZE)&& // 排除最小化样式
(rect.right-rect.left>5)&& // 增加宽度阈值
(rect.bottom-rect.top>5)&& // 增加高度阈值
(buf[0]!='\0')&&
(hwnd!=hWnd);
if(isValid) windowsRect.push_back(rect);
}
}
int collideY(int x,int y,int w,int h){
if(y<0) return 0;
if(y+h>srch) return srch-h;
for(auto& r:windowsRect){
if(inside(x,r.left,r.right)||inside(x+w,r.left,r.right)){
if(inside(r.top,y,y+h)){
if(y+h/2>r.top) return r.top;
return r.top-h;
}else if(inside(r.bottom,y,y+h)){
if(y+h/2<r.bottom) return r.bottom-h;
return r.bottom;
}
}
}
return -114514;
}
int collideX(int x,int y,int w,int h){
if(x<0) return 0;
if(x+w>srcw) return srcw-w;
for(auto& r:windowsRect){
if(inside(r.top,y,y+h)||inside(r.bottom,y,y+h)){
if(inside(r.left,x,x+w)) return r.left-w;
else if(inside(r.right,x,x+w)) return r.right;
}
}
return -114514;
}
void d(){
int tt = rand() % 256;
Sleep(100);
if(tt == 0){
system("color 11 ");
}
if(tt == 1){
system("color 12 ");
}
if(tt == 2){
system("color 13 ");
}
if(tt == 3){
system("color 14 ");
}
if(tt == 4){
system("color 15 ");
}
if(tt == 5){
system("color 16 ");
}
if(tt == 6){
system("color 17 ");
}
if(tt == 7){
system("color 18 ");
}
if(tt == 8){
system("color 19 ");
}
if(tt == 9){
system("color 1A ");
}
if(tt == 10){
system("color 1B ");
}
if(tt == 11){
system("color 1C ");
}
if(tt == 12){
system("color 1D ");
}
if(tt == 13){
system("color 1E ");
}
if(tt == 14){
system("color 1F ");
}
if(tt == 15){
system("color 21 ");
}
if(tt == 16){
system("color 22 ");
}
if(tt == 17){
system("color 23 ");
}
if(tt == 18){
system("color 24 ");
}
if(tt == 19){
system("color 25 ");
}
if(tt == 20){
system("color 26 ");
}
if(tt == 21){
system("color 27 ");
}
if(tt == 22){
system("color 28 ");
}
if(tt == 23){
system("color 29 ");
}
if(tt == 24){
system("color 2A ");
}
if(tt == 25){
system("color 2B ");
}
if(tt == 26){
system("color 2C ");
}
if(tt == 27){
system("color 2D ");
}
if(tt == 28){
system("color 2E ");
}
if(tt == 29){
system("color 2F ");
}
if(tt == 30){
system("color 31 ");
}
if(tt == 31){
system("color 32 ");
}
if(tt == 32){
system("color 33 ");
}
if(tt == 33){
system("color 34 ");
}
if(tt == 34){
system("color 35 ");
}
if(tt == 35){
system("color 36 ");
}
if(tt == 36){
system("color 37 ");
}
if(tt == 37){
system("color 38 ");
}
if(tt == 38){
system("color 39 ");
}
if(tt == 39){
system("color 3A ");
}
if(tt == 40){
system("color 3B ");
}
if(tt == 41){
system("color 3C ");
}
if(tt == 42){
system("color 3D ");
}
if(tt == 43){
system("color 3E ");
}
if(tt == 44){
system("color 3F ");
}
if(tt == 45){
system("color 41 ");
}
if(tt == 46){
system("color 42 ");
}
if(tt == 47){
system("color 43 ");
}
if(tt == 48){
system("color 44 ");
}
if(tt == 49){
system("color 45 ");
}
if(tt == 50){
system("color 46 ");
}
if(tt == 51){
system("color 47 ");
}
if(tt == 52){
system("color 48 ");
}
if(tt == 53){
system("color 49 ");
}
if(tt == 54){
system("color 4A ");
}
if(tt == 55){
system("color 4B ");
}
if(tt == 56){
system("color 4C ");
}
if(tt == 57){
system("color 4D ");
}
if(tt == 58){
system("color 4E ");
}
if(tt == 59){
system("color 4F ");
}
if(tt == 60){
system("color 51 ");
}
if(tt == 61){
system("color 52 ");
}
if(tt == 62){
system("color 53 ");
}
if(tt == 63){
system("color 54 ");
}
if(tt == 64){
system("color 55 ");
}
if(tt == 65){
system("color 56 ");
}
if(tt == 66){
system("color 57 ");
}
if(tt == 67){
system("color 58 ");
}
if(tt == 68){
system("color 59 ");
}
if(tt == 69){
system("color 5A ");
}
if(tt == 70){
system("color 5B ");
}
if(tt == 71){
system("color 5C ");
}
if(tt == 72){
system("color 5D ");
}
if(tt == 73){
system("color 5E ");
}
if(tt == 74){
system("color 5F ");
}
if(tt == 75){
system("color 61 ");
}
if(tt == 76){
system("color 62 ");
}
if(tt == 77){
system("color 63 ");
}
if(tt == 78){
system("color 64 ");
}
if(tt == 79){
system("color 65 ");
}
if(tt == 80){
system("color 66 ");
}
if(tt == 81){
system("color 67 ");
}
if(tt == 82){
system("color 68 ");
}
if(tt == 83){
system("color 69 ");
}
if(tt == 84){
system("color 6A ");
}
if(tt == 85){
system("color 6B ");
}
if(tt == 86){
system("color 6C ");
}
if(tt == 87){
system("color 6D ");
}
if(tt == 88){
system("color 6E ");
}
if(tt == 89){
system("color 6F ");
}
if(tt == 90){
system("color 71 ");
}
if(tt == 91){
system("color 72 ");
}
if(tt == 92){
system("color 73 ");
}
if(tt == 93){
system("color 74 ");
}
if(tt == 94){
system("color 75 ");
}
if(tt == 95){
system("color 76 ");
}
if(tt == 96){
system("color 77 ");
}
if(tt == 97){
system("color 78 ");
}
if(tt == 98){
system("color 79 ");
}
if(tt == 99){
system("color 7A ");
}
if(tt == 100){
system("color 7B ");
}
if(tt == 101){
system("color 7C ");
}
if(tt == 102){
system("color 7D ");
}
if(tt == 103){
system("color 7E ");
}
if(tt == 104){
system("color 7F ");
}
if(tt == 105){
system("color 81 ");
}
if(tt == 106){
system("color 82 ");
}
if(tt == 107){
system("color 83 ");
}
if(tt == 108){
system("color 84 ");
}
if(tt == 109){
system("color 85 ");
}
if(tt == 110){
system("color 86 ");
}
if(tt == 111){
system("color 87 ");
}
if(tt == 112){
system("color 88 ");
}
if(tt == 113){
system("color 89 ");
}
if(tt == 114){
system("color 8A ");
}
if(tt == 115){
system("color 8B ");
}
if(tt == 116){
system("color 8C ");
}
if(tt == 117){
system("color 8D ");
}
if(tt == 118){
system("color 8E ");
}
if(tt == 119){
system("color 8F ");
}
if(tt == 120){
system("color 91 ");
}
if(tt == 121){
system("color 92 ");
}
if(tt == 122){
system("color 93 ");
}
if(tt == 123){
system("color 94 ");
}
if(tt == 124){
system("color 95 ");
}
if(tt == 125){
system("color 96 ");
}
if(tt == 126){
system("color 97 ");
}
if(tt == 127){
system("color 98 ");
}
if(tt == 128){
system("color 99 ");
}
if(tt == 129){
system("color 9A ");
}
if(tt == 130){
system("color 9B ");
}
if(tt == 131){
system("color 9C ");
}
if(tt == 132){
system("color 9D ");
}
if(tt == 133){
system("color 9E ");
}
if(tt == 134){
system("color 9F ");
}
if(tt == 135){
system("color A1 ");
}
if(tt == 136){
system("color A2 ");
}
if(tt == 137){
system("color A3 ");
}
if(tt == 138){
system("color A4 ");
}
if(tt == 139){
system("color A5 ");
}
if(tt == 140){
system("color A6 ");
}
if(tt == 141){
system("color A7 ");
}
if(tt == 142){
system("color A8 ");
}
if(tt == 143){
system("color A9 ");
}
if(tt == 144){
system("color AA ");
}
if(tt == 145){
system("color AB ");
}
if(tt == 146){
system("color AC ");
}
if(tt == 147){
system("color AD ");
}
if(tt == 148){
system("color AE ");
}
if(tt == 149){
system("color AF ");
}
if(tt == 150){
system("color B1 ");
}
if(tt == 151){
system("color B2 ");
}
if(tt == 152){
system("color B3 ");
}
if(tt == 153){
system("color B4 ");
}
if(tt == 154){
system("color B5 ");
}
if(tt == 155){
system("color B6 ");
}
if(tt == 156){
system("color B7 ");
}
if(tt == 157){
system("color B8 ");
}
if(tt == 158){
system("color B9 ");
}
if(tt == 159){
system("color BA ");
}
if(tt == 160){
system("color BB ");
}
if(tt == 161){
system("color BC ");
}
if(tt == 162){
system("color BD ");
}
if(tt == 163){
system("color BE ");
}
if(tt == 164){
system("color BF ");
}
if(tt == 165){
system("color C1 ");
}
if(tt == 166){
system("color C2 ");
}
if(tt == 167){
system("color C3 ");
}
if(tt == 168){
system("color C4 ");
}
if(tt == 169){
system("color C5 ");
}
if(tt == 170){
system("color C6 ");
}
if(tt == 171){
system("color C7 ");
}
if(tt == 172){
system("color C8 ");
}
if(tt == 173){
system("color C9 ");
}
if(tt == 174){
system("color CA ");
}
if(tt == 175){
system("color CB ");
}
if(tt == 176){
system("color CC ");
}
if(tt == 177){
system("color CD ");
}
if(tt == 178){
system("color CE ");
}
if(tt == 179){
system("color CF ");
}
if(tt == 180){
system("color D1 ");
}
if(tt == 181){
system("color D2 ");
}
if(tt == 182){
system("color D3 ");
}
if(tt == 183){
system("color D4 ");
}
if(tt == 184){
system("color D5 ");
}
if(tt == 185){
system("color D6 ");
}
if(tt == 186){
system("color D7 ");
}
if(tt == 187){
system("color D8 ");
}
if(tt == 188){
system("color D9 ");
}
if(tt == 189){
system("color DA ");
}
if(tt == 190){
system("color DB ");
}
if(tt == 191){
system("color DC ");
}
if(tt == 192){
system("color DD ");
}
if(tt == 193){
system("color DE ");
}
if(tt == 194){
system("color DF ");
}
if(tt == 195){
system("color E1 ");
}
if(tt == 196){
system("color E2 ");
}
if(tt == 197){
system("color E3 ");
}
if(tt == 198){
system("color E4 ");
}
if(tt == 199){
system("color E5 ");
}
if(tt == 200){
system("color E6 ");
}
if(tt == 201){
system("color E7 ");
}
if(tt == 202){
system("color E8 ");
}
if(tt == 203){
system("color E9 ");
}
if(tt == 204){
system("color EA ");
}
if(tt == 205){
system("color EB ");
}
if(tt == 206){
system("color EC ");
}
if(tt == 207){
system("color ED ");
}
if(tt == 208){
system("color EE ");
}
if(tt == 209){
system("color EF ");
}
if(tt == 210){
system("color F1 ");
}
if(tt == 211){
system("color F2 ");
}
if(tt == 212){
system("color F3 ");
}
if(tt == 213){
system("color F4 ");
}
if(tt == 214){
system("color F5 ");
}
if(tt == 215){
system("color F6 ");
}
if(tt == 216){
system("color F7 ");
}
if(tt == 217){
system("color F8 ");
}
if(tt == 218){
system("color F9 ");
}
if(tt == 219){
system("color FA ");
}
if(tt == 220){
system("color FB ");
}
if(tt == 221){
system("color FC ");
}
if(tt == 222){
system("color FD ");
}
if(tt == 223){
system("color FE ");
}
if(tt == 224){
system("color FF ");
}
}
bool IsMouseOverCloseButton(HWND hwnd) {
// 获取窗口矩形
RECT windowRect;
GetWindowRect(hwnd, &windowRect);
// 获取鼠标位置
POINT mousePos;
GetCursorPos(&mousePos);
// 计算关闭按钮区域(通常在右上角)
RECT closeButtonRect = {
windowRect.right - 20, // 假设关闭按钮宽度为20
windowRect.top,
windowRect.right,
windowRect.top + 20 // 假设关闭按钮高度为20
};
// 检查鼠标是否在关闭按钮区域内
return PtInRect(&closeButtonRect, mousePos);
}
int main(){
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
int op = 60;
float x=1,y=1,sx=0,sy=0,cx=200,cy=200,cyy=0;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
system("cls");
cout << " \n";
cout << " \n";
cout << "Hi~ o(* ̄▽ ̄*)ブ \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
op = 100;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
int now_f = -1, opp = 0, f = 1, fff = 0, sum = 0;
while(1){
if(sum >= 5){
system("cls");
cout << "\n";
cout << "I'm angry! \n";
cout << " (╬▔^▔)╯ \n";
op = 200;
sum = 0;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(opp >= 3){
// now_f = 3;
opp = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " ╥﹏╥ \n";
op = 30;
sum ++;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(y <= 200 && now_f != 1){
now_f = 1;
fff = 1;
system("cls");
cout << "\n";
cout << " \n";
cout << " (._.`) \n";
}else if(fff == 1 && now_f != 2 && y > 200 && y <= 300){
now_f = 2;
fff = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " >﹏< \n";
}else if(now_f == 2 && sy == 0){
// now_f = 3;
opp ++;
if(opp == 1){
system("cls");
cout << "\n";
cout << " \n";
cout << " ⊙﹏⊙ \n";
}
}else if(now_f == -1 && f){
now_f = -1;
f = 0;
system("cls");
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";0 1720
// cout << " \n";1 848.5
// cout << " \n";147 878
// cout << " \n";191 878
// cout << " \n";147 850
// cout << " \n";191 850
cout << " ";
}
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
d();
Sleep(20);
}
return 0;
}
乒乓球型
#include<iostream>
#include<windows.h>
#include<vector>
using namespace std;
HWND hWnd=GetForegroundWindow();
int srcw=GetSystemMetrics(SM_CXSCREEN);
int srch=GetSystemMetrics(SM_CYSCREEN);
bool key[4];//WSAD
POINT mousepos;
void getkey(){
key[0]=(GetAsyncKeyState('W')|GetAsyncKeyState(VK_UP))&0x8000;
key[1]=(GetAsyncKeyState('S')|GetAsyncKeyState(VK_DOWN))&0x8000;
key[2]=(GetAsyncKeyState('A')|GetAsyncKeyState(VK_LEFT))&0x8000;
key[3]=(GetAsyncKeyState('D')|GetAsyncKeyState(VK_RIGHT))&0x8000;
}
bool inline inside(int x,int y,int w,int h,int mx,int my){
return mx>=x&&mx<x+w&&my>=y&&my<y+h;
}
bool inline inside(int x,int l,int r){
return x>l&&x<r;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam){
vector<HWND>* data=reinterpret_cast<vector<HWND>*>(lParam);
data->push_back(hwnd);
return TRUE;
}
vector<RECT> windowsRect;
vector<HWND> hwnds;
void getWindowsRect(){
windowsRect.clear();
//static vector<HWND> hwnds;
hwnds.clear();RECT rect;
EnumWindows(EnumWindowsProc,(LPARAM)&hwnds);
for(int i=0; i<hwnds.size(); i++) {
HWND hwnd=hwnds[i];
GetWindowRect(hwnd,&rect);
char buf[256]={0};
GetWindowText(hwnd,buf,sizeof(buf));
LONG style=GetWindowLong(hwnd,GWL_STYLE);
LONG exStyle=GetWindowLong(hwnd,GWL_EXSTYLE);
bool isValid=
IsWindowVisible(hwnd)&& // 排除不可见窗口
!IsIconic(hwnd)&& // 排除最小化窗口
(style&WS_VISIBLE)&& // 必须包含可见样式
!(style&WS_MINIMIZE)&& // 排除最小化样式
(rect.right-rect.left>5)&& // 增加宽度阈值
(rect.bottom-rect.top>5)&& // 增加高度阈值
(buf[0]!='\0')&&
(hwnd!=hWnd);
if(isValid) windowsRect.push_back(rect);
}
}
int collideY(int x,int y,int w,int h){
if(y<0) return 0;
if(y+h>srch) return srch-h;
for(auto& r:windowsRect){
if(inside(x,r.left,r.right)||inside(x+w,r.left,r.right)){
if(inside(r.top,y,y+h)){
if(y+h/2>r.top) return r.top;
return r.top-h;
}else if(inside(r.bottom,y,y+h)){
if(y+h/2<r.bottom) return r.bottom-h;
return r.bottom;
}
}
}
return -114514;
}
int collideX(int x,int y,int w,int h){
if(x<0) return 0;
if(x+w>srcw) return srcw-w;
for(auto& r:windowsRect){
if(inside(r.top,y,y+h)||inside(r.bottom,y,y+h)){
if(inside(r.left,x,x+w)) return r.left-w;
else if(inside(r.right,x,x+w)) return r.right;
}
}
return -114514;
}
bool IsMouseOverCloseButton(HWND hwnd) {
// 获取窗口矩形
RECT windowRect;
GetWindowRect(hwnd, &windowRect);
// 获取鼠标位置
POINT mousePos;
GetCursorPos(&mousePos);
// 计算关闭按钮区域(通常在右上角)
RECT closeButtonRect = {
windowRect.right - 20, // 假设关闭按钮宽度为20
windowRect.top,
windowRect.right,
windowRect.top + 20 // 假设关闭按钮高度为20
};
// 检查鼠标是否在关闭按钮区域内
return PtInRect(&closeButtonRect, mousePos);
}
int main(){
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
int op = 60;
float x=1,y=1,sx=0,sy=0,cx=200,cy=200,cyy=0;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
system("cls");
cout << " \n";
cout << " \n";
cout << "Hi~ o(* ̄▽ ̄*)ブ \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
op = 100;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
int now_f = -1, opp = 0, f = 1, fff = 0, sum = 0;
while(1){
y -= 10;
Sleep(2);
if(sum >= 5){
system("cls");
cout << "\n";
cout << "I'm angry! \n";
cout << " (╬▔^▔)╯ \n";
op = 200;
sum = 0;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(opp >= 3){
// now_f = 3;
opp = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " ╥﹏╥ \n";
op = 30;
sum ++;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(y <= 200 && now_f != 1){
now_f = 1;
fff = 1;
system("cls");
cout << "\n";
cout << " \n";
cout << " (._.`) \n";
}else if(fff == 1 && now_f != 2 && y > 200 && y <= 300){
now_f = 2;
fff = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " >﹏< \n";
}else if(now_f == 2 && sy == 0){
// now_f = 3;
opp ++;
if(opp == 1){
system("cls");
cout << "\n";
cout << " \n";
cout << " ⊙﹏⊙ \n";
}
}else if(now_f == -1 && f){
now_f = -1;
f = 0;
system("cls");
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";0 1720
// cout << " \n";1 848.5
// cout << " \n";147 878
// cout << " \n";191 878
// cout << " \n";147 850
// cout << " \n";191 850
cout << " ";
}
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
// Sleep(20);
}
return 0;
}
彩色表情包
#include<iostream>
#include<windows.h>
#include<vector>
using namespace std;
HWND hWnd=GetForegroundWindow();
int srcw=GetSystemMetrics(SM_CXSCREEN);
int srch=GetSystemMetrics(SM_CYSCREEN);
bool key[4];//WSAD
POINT mousepos;
void getkey(){
key[0]=(GetAsyncKeyState('W')|GetAsyncKeyState(VK_UP))&0x8000;
key[1]=(GetAsyncKeyState('S')|GetAsyncKeyState(VK_DOWN))&0x8000;
key[2]=(GetAsyncKeyState('A')|GetAsyncKeyState(VK_LEFT))&0x8000;
key[3]=(GetAsyncKeyState('D')|GetAsyncKeyState(VK_RIGHT))&0x8000;
}
bool inline inside(int x,int y,int w,int h,int mx,int my){
return mx>=x&&mx<x+w&&my>=y&&my<y+h;
}
bool inline inside(int x,int l,int r){
return x>l&&x<r;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam){
vector<HWND>* data=reinterpret_cast<vector<HWND>*>(lParam);
data->push_back(hwnd);
return TRUE;
}
vector<RECT> windowsRect;
vector<HWND> hwnds;
void getWindowsRect(){
windowsRect.clear();
//static vector<HWND> hwnds;
hwnds.clear();RECT rect;
EnumWindows(EnumWindowsProc,(LPARAM)&hwnds);
for(int i=0; i<hwnds.size(); i++) {
HWND hwnd=hwnds[i];
GetWindowRect(hwnd,&rect);
char buf[256]={0};
GetWindowText(hwnd,buf,sizeof(buf));
LONG style=GetWindowLong(hwnd,GWL_STYLE);
LONG exStyle=GetWindowLong(hwnd,GWL_EXSTYLE);
bool isValid=
IsWindowVisible(hwnd)&& // 排除不可见窗口
!IsIconic(hwnd)&& // 排除最小化窗口
(style&WS_VISIBLE)&& // 必须包含可见样式
!(style&WS_MINIMIZE)&& // 排除最小化样式
(rect.right-rect.left>5)&& // 增加宽度阈值
(rect.bottom-rect.top>5)&& // 增加高度阈值
(buf[0]!='\0')&&
(hwnd!=hWnd);
if(isValid) windowsRect.push_back(rect);
}
}
int collideY(int x,int y,int w,int h){
if(y<0) return 0;
if(y+h>srch) return srch-h;
for(int i=0;i<windowsRect.size();i++){
if(inside(x,windowsRect[i].left,windowsRect[i].right)||inside(x+w,windowsRect[i].left,windowsRect[i].right)){
if(inside(windowsRect[i].top,y,y+h)){
if(y+h/2>windowsRect[i].top) return windowsRect[i].top;
return windowsRect[i].top-h;
}else if(inside(windowsRect[i].bottom,y,y+h)){
if(y+h/2<windowsRect[i].bottom) return windowsRect[i].bottom-h;
return windowsRect[i].bottom;
}
}
}
return -114514;
}
int collideX(int x,int y,int w,int h){
if(x<0) return 0;
if(x+w>srcw) return srcw-w;
for(int i=0;i<windowsRect.size();i++){
if(inside(windowsRect[i].top,y,y+h)||inside(windowsRect[i].bottom,y,y+h)){
if(inside(windowsRect[i].left,x,x+w)) return windowsRect[i].left-w;
else if(inside(windowsRect[i].right,x,x+w)) return windowsRect[i].right;
}
}
return -114514;
}
bool IsMouseOverCloseButton(HWND hwnd) {
// 获取窗口矩形
RECT windowRect;
GetWindowRect(hwnd, &windowRect);
// 获取鼠标位置
POINT mousePos;
GetCursorPos(&mousePos);
// 计算关闭按钮区域(通常在右上角)
RECT closeButtonRect = {
windowRect.right - 20, // 假设关闭按钮宽度为20
windowRect.top,
windowRect.right,
windowRect.top + 20 // 假设关闭按钮高度为20
};
// 检查鼠标是否在关闭按钮区域内
return PtInRect(&closeButtonRect, mousePos);
}
int main(){
system("color e2");
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
int op = 60;
float x=1,y=1,sx=0,sy=0,cx=200,cy=200,cyy=0;
while(op --){
system("color e2");
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
system("cls");
cout << " \n";
cout << " \n";
cout << "Hi~ o(* ̄▽ ̄*)ブ \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
// cout << " \n";
cout << " ";
op = 100;
while(op --){
system("color e2");
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
int now_f = -1, opp = 0, f = 1, fff = 0, sum = 0;
while(1){
if(sum >= 5){
system("color 40");
system("cls");
cout << "\n";
cout << "I'm angry! \n";
cout << " (╬▔^▔)╯ \n";
op = 200;
sum = 0;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(opp >= 3){
system("color e9");
// now_f = 3;
opp = 0;
system("cls");
cout << "\n";
cout << " \n";
cout << " ╥﹏╥ \n";
op = 30;
sum ++;
while(op --){
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
now_f = -1;
f = 1;
}else if(y <= 200 && now_f != 1){
now_f = 1;
fff = 1;
system("cls");
system("color e2");
cout << "\n";
cout << " \n";
cout << " (._.`) \n";
}else if(fff == 1 && now_f != 2 && y > 200 && y <= 300){
now_f = 2;
fff = 0;
system("cls");
system("color f2");
cout << "\n";
cout << " \n";
cout << " >﹏< \n";
}else if(now_f == 2 && sy == 0){
// now_f = 3;
opp ++;
if(opp == 1){
system("cls");
system("color f2");
cout << "\n";
cout << " \n";
cout << " ⊙﹏⊙ \n";
}
}else if(now_f == -1 && f){
system("color e2");
now_f = -1;
f = 0;
system("cls");
cout << " \n";
cout << " \n";
cout << " O( ∩ _ ∩ )O \n";
// cout << " \n";0 1720
// cout << " \n";1 848.5
// cout << " \n";147 878
// cout << " \n";191 878
// cout << " \n";147 850
// cout << " \n";191 850
cout << " ";
}
getkey();
POINT pt;
GetCursorPos(&mousepos);
getWindowsRect();
sx+=(key[3]-key[2]);sy+=0.5f;
// cout << x + 146 << " " << mousepos.x << "\n";
if(mousepos.x >= x + 146 && mousepos.x <= x + 190 && mousepos.y >= y + 2 && mousepos.y <= y + 30){
if(x - 100 < 0){
x += 100;
}else{
x -= 100;
}
if(y - 100 < 0){
y += 100;
}else{
y -= 100;
}
}
if(key[0])
if(collideY(x,y,cx,cy+2)!=-114514||inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2))
sy=-15;
y+=sy;
if(inside(x,y+cy*0.8f,cx,cy*0.2f,mousepos.x,mousepos.y-2)){ y=mousepos.y-cy;sy=0; }
int c=collideY(x,y,cx,cy);
if(c!=-114514){ y=c;sy=0; }
x+=sx;
if(inside(x,y+cy*0.2f,cx,cy*0.6f,mousepos.x,mousepos.y)){
if(x+cx/2>mousepos.x) x=mousepos.x;
else x=mousepos.x-cx;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
c=collideX(x,y,cx,cy);
if(c!=-114514){
x=c;
if(key[0]){ sy=-15;sx=sx<0?10:-10; }else sx=0;
}
sx*=0.9f;
cyy+=(key[1]*cy/2-cyy)*0.5f;
SetWindowPos(hWnd,HWND_TOPMOST,x,y+cyy,cx,cy-cyy,SWP_SHOWWINDOW);
Sleep(20);
}
return 0;
}