社区讨论
模拟游戏进度条
灌水区参与者 6已保存回复 10
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 10 条
- 当前快照
- 1 份
- 快照标识符
- @lzs5z20h
- 此快照首次捕获于
- 2024/08/13 16:31 2 年前
- 此快照最后确认于
- 2024/08/13 18:44 2 年前
还有可能加载出错哟!
CPP#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
using namespace std;
void ys(int a) {
if (a == 0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
if (a == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
if (a == 2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
if (a == 3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
if (a == 4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
if (a == 5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
if (a >= 6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
}
void SetPos(int x, int y) {
COORD pos;
pos.X = y, pos.Y = x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
signed main() {
cout << setw(50) << "欢迎来到游戏\n";
cout << setw(50) << "按任意键进入\n";
int l = getch();
system("cls");
srand(time(0));
ys(1);
int i;
int c = rand() % 10 + 1;
if (c == 1) {
MessageBox(NULL,"加载出错","游戏",MB_OK);
exit(0);
}
cout << "\n %\n 正在加载中...";
for (i = 1; i <= 99; i++) {
int y = rand() % 502;
int x = rand() % y;
SetPos(0, i);
cout << "█";
if (i > 9) {
SetPos(1,48);
} else {
SetPos(1,49);
}
cout << i;
Sleep(x);
}
system("cls");
}
回复
共 10 条回复,欢迎继续交流。
正在加载回复...