正文
增加 12 行删除 12 行
107 行未改动全部展开108109110111112113114115116157 行未改动全部展开2742752762772782792802812825 行未改动28828929029129229329429529629729829930030130230330430578 行未改动384385386387388389390391392288 行未改动全部展开6816826836846856866876886896906915 行未改动6976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317323 行未改动736737738739740741742743744214 行未改动全部展开107 行未改动全部展开HBRUSH brush = CreateSolidBrush(RGB(255, 0, 0)); // 红色激光SelectObject(hdc, brush);RECT rect;GetClientRect(hwnd, &rect);// 绘制激光线 - 使用Rectangle绘制一个细长的矩形FillRect(hdc, &rect, brush);DeleteObject(brush);157 行未改动全部展开// 创建激光void CreateLaser(bool isHorizontal, int position, int direction = 1) {int laserWidth, laserHeight;int x, y;if (isHorizontal) {// 横向激光laserWidth = maxx; // 横跨整个屏幕宽度laserHeight = 5; // 高度为5像素5 行未改动laserHeight = maxy; // 高度为整个屏幕高度x = position;y = 0;}Laser newLaser;newLaser.hwnd = CreateLaserWindow(x, y, laserWidth, laserHeight);newLaser.x = x;newLaser.y = y;newLaser.length = isHorizontal ? maxx : maxy;newLaser.isHorizontal = isHorizontal;newLaser.active = true;newLaser.direction = direction;lasers.push_back(newLaser);}// 显示激光预警78 行未改动// 检测玩家与激光的碰撞bool CheckLaserCollision(double px, double py) {for(size_t i = 0; i < lasers.size(); i++) {if (!lasers[i].active) continue;if (lasers[i].isHorizontal) {// 横向激光if (py >= lasers[i].y && py <= lasers[i].y + 5) { // 激光高度为5像素if (px >= lasers[i].x && px <= lasers[i].x + maxx) {288 行未改动全部展开static DWORD lastLaserTime = GetTickCount();static bool warningShown = false;static DWORD warningStartTime = 0;static DWORD laserActivationTime = 0;DWORD currentTime = GetTickCount();// 检查是否到了生成新激光的时间if (currentTime - lastLaserTime > (rand() % 5000 + 10000)) { // 10-15秒if (!warningShown) {// 显示预警5 行未改动}warningShown = true;warningStartTime = currentTime;}// 等待1.5秒后激活激光if (warningShown && currentTime - warningStartTime > 1500) {bool horizontal = rand() % 2 == 0; // 随机选择方向int position;if (horizontal) {position = rand() % maxy; // 在屏幕高度内随机选择y坐标} else {position = rand() % maxx; // 在屏幕宽度内随机选择x坐标}CreateLaser(horizontal, position);laserActivationTime = currentTime;lastLaserTime = currentTime; // 重置计时器warningShown = false;}}// 检查激光是否应该消失(持续5秒)for(size_t i = 0; i < lasers.size(); i++) {if (currentTime - laserActivationTime > 5000) { // 5秒后消失if (lasers[i].active) {DestroyWindow(lasers[i].hwnd);lasers[i].active = false;}}}// 清理已失效的激光for(int i = lasers.size() - 1; i >= 0; i--) {if (!lasers[i].active && GetTickCount() - laserActivationTime > 5500) {lasers.erase(lasers.begin() + i);3 行未改动int main(){// 初始化COM(某些对话框可能需要)CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);// 初始化随机数种子srand(time(NULL));HWND conso=GetConsoleWindow();214 行未改动全部展开107 行未改动全部展开108109110111112113114115116157 行未改动全部展开2742752762772782792802812825 行未改动28828929029129229329429529629729829930030130230330430578 行未改动384385386387388389390391392288 行未改动全部展开6816826836846856866876886896906915 行未改动6976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317323 行未改动736737738739740741742743744214 行未改动全部展开107 行未改动全部展开HBRUSH brush = CreateSolidBrush(RGB(255, 0, 0)); // 红色激光SelectObject(hdc, brush);RECT rect;GetClientRect(hwnd, &rect);// 绘制激光线 - 使用Rectangle绘制一个细长的矩形FillRect(hdc, &rect, brush);DeleteObject(brush);157 行未改动全部展开// 创建激光void CreateLaser(bool isHorizontal, int position, int direction = 1) {int laserWidth, laserHeight;int x, y;if (isHorizontal) {// 横向激光laserWidth = maxx; // 横跨整个屏幕宽度laserHeight = 5; // 高度为5像素5 行未改动laserHeight = maxy; // 高度为整个屏幕高度x = position;y = 0;}Laser newLaser;newLaser.hwnd = CreateLaserWindow(x, y, laserWidth, laserHeight);newLaser.x = x;newLaser.y = y;newLaser.length = isHorizontal ? maxx : maxy;newLaser.isHorizontal = isHorizontal;newLaser.active = true;newLaser.direction = direction;lasers.push_back(newLaser);}// 显示激光预警78 行未改动// 检测玩家与激光的碰撞bool CheckLaserCollision(double px, double py) {for(size_t i = 0; i < lasers.size(); i++) {if (!lasers[i].active) continue;if (lasers[i].isHorizontal) {// 横向激光if (py >= lasers[i].y && py <= lasers[i].y + 5) { // 激光高度为5像素if (px >= lasers[i].x && px <= lasers[i].x + maxx) {288 行未改动全部展开static DWORD lastLaserTime = GetTickCount();static bool warningShown = false;static DWORD warningStartTime = 0;static DWORD laserActivationTime = 0;DWORD currentTime = GetTickCount();// 检查是否到了生成新激光的时间if (currentTime - lastLaserTime > (rand() % 5000 + 10000)) { // 10-15秒if (!warningShown) {// 显示预警5 行未改动}warningShown = true;warningStartTime = currentTime;}// 等待1.5秒后激活激光if (warningShown && currentTime - warningStartTime > 1500) {bool horizontal = rand() % 2 == 0; // 随机选择方向int position;if (horizontal) {position = rand() % maxy; // 在屏幕高度内随机选择y坐标} else {position = rand() % maxx; // 在屏幕宽度内随机选择x坐标}CreateLaser(horizontal, position);laserActivationTime = currentTime;lastLaserTime = currentTime; // 重置计时器warningShown = false;}}// 检查激光是否应该消失(持续5秒)for(size_t i = 0; i < lasers.size(); i++) {if (currentTime - laserActivationTime > 5000) { // 5秒后消失if (lasers[i].active) {DestroyWindow(lasers[i].hwnd);lasers[i].active = false;}}}// 清理已失效的激光for(int i = lasers.size() - 1; i >= 0; i--) {if (!lasers[i].active && GetTickCount() - laserActivationTime > 5500) {lasers.erase(lasers.begin() + i);3 行未改动int main(){// 初始化COM(某些对话框可能需要)CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);// 初始化随机数种子srand(time(NULL));HWND conso=GetConsoleWindow();214 行未改动全部展开