跳到正文

linyuhang0927

1257202

人活一生,值得爱的东西很多,不要因为一个不满意,就灰心。

在洛谷打开
资料、奖项与版本

资料

编号
1257202
抓取
  1. 贝利亚

https://www.arealme.com/mouse-test/cn/

https://www.cnblogs.com/fxc070830/p/fxc070830.html

https://seve42.github.io/OItrainer/start.html

C++
#include <bits/stdc++.h>
#include <iostream>
#include <random>
#include <string>
#include <windows.h>
using namespace std;
int c = 15;
bool a[20][20];

void typewriterEx(const string &text, int speed = 50, bool randomSpeed = false) {
	for (char c : text) {
		cout << c << flush;
		Sleep(randomSpeed ? rand() % 100 + 10 : speed);
	}
}

//初始界面
void start(int c) {
	system("cls");
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hConsole, c);
	typewriterEx("1.开始游戏\n", 20);
	typewriterEx("2.选择颜色\n", 20);
	typewriterEx("3.退出游戏\n", 20);
}

void tan() {
	std::random_device rd;
	std::mt19937 gen(rd());
	std::uniform_int_distribution<> disx(2, 19);
	std::uniform_int_distribution<> disy(2, 19);
	std::cout << "\033[2J\033[1;1H";
	int x = disx(gen);
	int y = disy(gen);
	for (int i = 1; i <= 20; i++) {
		cout << "--";
	}
	cout << "\n";
	for (int j = 1; j <= 18; j++) {
		cout << "|";
		for (int i = 1; i <= 18; i++) {
			if (a[j][i]) {
				cout << "■";
			} else if (j == x && i == y) {
				cout << "●";
			} else {
				cout << "  ";
			}
		}
		cout << "|" << "\n";
	}
	for (int i = 1; i <= 20; i++) {
		cout << "--";
	}
	for (int i = 20; i >= 1; i--) {
		for (int j = 20; j >= 1; j--) {
			if (a[i][j]) {
				a[i][j] = 0;
				a[i + 1][j] = 1;
			}
		}
	}
	this_thread::sleep_for(chrono::seconds(1));
	tan();
}

void jieshao(int c) {
	while (1) {
		system("cls");
		std::cout << "\033[2J\033[1;1H";
		HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleTextAttribute(hConsole, c);
		typewriterEx("1.2048\n", 20);
		typewriterEx("2.贪吃蛇\n", 20);
		typewriterEx("3.返回\n", 20);
		int x;
		cin >> x;
		if (x == 1) {
			std::cout << "\033[2J\033[1;1H";
			typewriterEx("暂无\n", 20);
			this_thread::sleep_for(chrono::seconds(1));
		} else if (x == 2) {
			a[10][10] = 1;
			a[9][10] = 1;
			std::cout << "\033[2J\033[1;1H";
			tan();
			this_thread::sleep_for(chrono::seconds(1));
		} else {
			return;
		}
	}
}

void xuanzhe() {
	system("cls");
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hConsole, 1);
	typewriterEx("1:蓝色\n", 20);
	SetConsoleTextAttribute(hConsole, 2);
	typewriterEx("2:绿色\n", 20);
	SetConsoleTextAttribute(hConsole, 3);
	typewriterEx("3:浅绿色\n", 20);
	SetConsoleTextAttribute(hConsole, 4);
	typewriterEx("4:红色\n", 20);
	SetConsoleTextAttribute(hConsole, 5);
	typewriterEx("5:紫色\n", 20);
	SetConsoleTextAttribute(hConsole, 6);
	typewriterEx("6:黄色\n", 20);
	SetConsoleTextAttribute(hConsole, 7);
	typewriterEx("7:白色\n", 20);
	SetConsoleTextAttribute(hConsole, 8);
	typewriterEx("8:灰色\n", 20);
	SetConsoleTextAttribute(hConsole, 9);
	typewriterEx("9:淡蓝色\n", 20);
	SetConsoleTextAttribute(hConsole, 10);
	typewriterEx("10:淡绿色\n", 20);
	SetConsoleTextAttribute(hConsole, 11);
	typewriterEx("11:淡浅绿色\n", 20);
	SetConsoleTextAttribute(hConsole, 12);
	typewriterEx("12:淡红色\n", 20);
	SetConsoleTextAttribute(hConsole, 13);
	typewriterEx("13:淡紫色\n", 20);
	SetConsoleTextAttribute(hConsole, 14);
	typewriterEx("14:淡黄色\n", 20);
	SetConsoleTextAttribute(hConsole, 15);
	typewriterEx("15:亮白色\n", 20);
	typewriterEx("0:彩蛋\n", 20);
	cin >> c;
	if (c == 0) {
		typewriterEx("恭喜解锁黑色字体\n", 20);
	}
}

void jieshu() {
	system("cls");
	std::cout << "\033[2J\033[1;1H";
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hConsole, c);
	typewriterEx("再见\n", 20);
}

int main() {
	std::cout << "\033[2J\033[1;1H";
	while (1) {
		std::cout << "\033[2J\033[1;1H";
		start(c);
		int a;
		cin >> a;
		if (a == 1) {
			jieshao(c);
		} else if (a == 2) {
			xuanzhe();
		} else {
			jieshu();
			return 0;
		}
	}

//	SetConsoleTextAttribute(hConsole, 11);
//	typewriterEx("★ 支持随机速度输出\n", 0, true);

	return 0;
}

还没有收录这位用户的文章。