复刻Hurt Umpass

仅以记录

曾经有一位先人

为了某种目的

编写了一个程序

它讲述了一位勇士的故事

这位勇士翻山越岭

翻雪山,过草地

最终来到了一个山洞前

勇士走了进去

在迷宫中前行

就算下一秒就会粉身碎骨

但他还是继续前进

最终

他(设计者)找到了自己的目标

从身后取下了弓箭

“嗖”的一声

故事结束了......

// Hunt Umpass.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
// By Rzj.
//20:37 2022.4.8

#include <iostream>
#include <cstdlib>
#include <Windows.h>
#include <cstring>

using namespace std;

class Player
{
public:
	int x = 5;
	int y = 9;
	int b = 3;
	string name = "Jim";
	void ShowPos();
};
//Player类
class Umpass {
public:
	int x = 2;
	int y = 1;
	string name = "Umpass";
	void ShowPos();
};

void ShowArray(int[10][10], Player);
//显示一个二维数组
void OutputCommand();
//显示所有命令
void Exit();
//ExitProgram
void ListenThePos(Player user);

int main()
{
	bool Editor = true;
	Player user;
	int map[10][10] = {
		{0, 1, 1, 1, 0, 0, 0, 0, 0, 0},
		{0, 1, 0, 1, 0, 0, 0, 0, 0, 0},
		{0, 1, 0, 0, 0, 0, 1, 0, 0, 0},
		{0, 1, 0, 0, 1, 0, 0, 0, 0, 0},
		{1, 1, 1, 0, 0, 0, 0, 0, 0, 0},
		{1, 1, 0, 0, 0, 0, 0, 0, 1, 0},
		{1, 1, 1, 0, 0, 0, 0, 0, 1, 0},
		{0, 0, 0, 0, 0, 1, 0, 0, 1, 0},
		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
	};
	string command;
	cout << "==========欢迎来到乌姆帕斯的世界==========\n" << endl;
	if (!(Editor)) {
		for (int i = 0; i < 101; i++) {
			Sleep(4);
			cout << "Loding " << i << "%" << endl;
		}
		Sleep(500);
		cout << "\nEnded!" << endl;
	}
	while (true) {
		ShowArray(map, user);
		cout << "您的位置: ";
		cout << "Command: ";
		cin >> command;
		if (command == "--help" || command == "-h")
			OutputCommand();
		else if (command == "向北走") {
			if ((user.y > 0) && (map[user.y - 1][user.x] == 0)) {
				user.y -= 1;
				cout << "您向北走了一格" << endl;
			}
			else if (user.y == 0)
				cout << "您所处的位置是山洞的最北面,无法再往北走了!" << endl;
			else if (map[user.y - 1][user.x] == 1)
				cout << "您的北面是死路" << endl;
		}
		else if (command == "向南走") {
			if ((user.y < 9) && (map[user.y + 1][user.x] == 0)) {
				user.y += 1;
				cout << "您向南走了一格" << endl;
			}
			else if (user.y == 9)
				cout << "您所处的位置是山洞的最南面,无法再往南走了!" << endl;
			else if (map[user.y + 1][user.x] == 1)
				cout << "您的南面是死路" << endl;
		}
		else if (command == "向东走") {
			if ((user.x < 9) && (map[user.y][user.x + 1] == 0)) {
				user.x += 1;
				cout << "您向东走了一格" << endl;
			}
			else if (user.x == 9)
				cout << "您所处的位置是山洞的最东面,无法再往东走了!" << endl;
			else if (map[user.y][user.x + 1] == 1)
				cout << "您的东面是死路" << endl;
		}
		else if (command == "向西走") {
			if ((user.x > 0) && (map[user.y][user.x - 1] == 0)) {
				user.x -= 1;
				cout << "您向西走了一格" << endl;
			}
			else if (user.x == 0)
				cout << "您所处的位置是山洞的最西面,无法再往西走了!" << endl;
			else if (map[user.y][user.x - 1] == 1)
				cout << "您的西面是死路" << endl;
		}
		else if (command == "射箭") {
			if (user.b > 0) {
				user.b -= 1;
				cout << "您射出了致命的一箭!" << endl;
				Sleep(400);
				cout << "可是没有射中!" << endl;
			}
			else if (user.b == 0)
				cout << "您没有箭了!" << endl;
		}
		else
			cout << "指令无法接受,输入--help查看全部指令\n" << endl;
		ListenThePos(user);
		
	}

}

void ShowArray(int Array[10][10], Player user) {
	for (int i = 0; i < 10; i++) {
		for (int k = 0; k < 10; k++) {
			if (k == user.x && i == user.y)
				cout << "@" << " ";
			else
				cout << Array[i][k] << " ";
		}
		cout << endl;
	}
}

void OutputCommand() {
	cout << "命令               结果\n";
	cout << "向北走             向北走一格\n";
	cout << "向南走             向南走一格\n";
	cout << "向东走             向东走一格\n";
	cout << "向西走             向西走一格\n";
	cout << "射箭               射出致命的一箭\n";
	cout << endl;
}

void Exit() {
	string s;
	cout << "\nEnter some text to exit.";
	cin >> s;
	exit(0);
}
void ListenThePos(Player user) {
	//遇见乌姆帕斯
	int Pitfall[][2] = { {2, 3} };
	string command;
	if (user.x == 2 && user.y == 2) {
		cout << "您遇见了乌姆帕斯!" << endl;
		cout << "Command: ";
		cin >> command;
		if (command == "射箭" && user.b > 0) {
			user.b -= 1;
			Sleep(200);
			cout << "乌姆帕斯已死亡!" << endl;
			Sleep(800);
			cout << "游戏结束";
			Exit();
		}
		else if (user.b == 0)
			cout << "您没有箭了!" << endl;
		else
			cout << "很可惜,您错过了一次完美的机会!" << endl;
	}
	for (int i = 0; i < 1; i++) {
		if (user.x == Pitfall[i][0] && user.y == Pitfall[i][1]) {
			cout << "您碰到了陷阱!\n";
			Sleep(500);
			cout << "您死了!\n";
			Exit();
		}
		else if (user.x == Pitfall[i][0] && Pitfall[i][1] + 1) {
			cout << "从北面传来了一阵风!\n";
			Sleep(500);
		}
		else if (user.x == Pitfall[i][0] && user.y == Pitfall[i][1] - 1) {
			cout << "从南面传来了一阵风!\n";
			Sleep(500);
		}
		else if (user.x == Pitfall[i][0] + 1 && user.y == Pitfall[i][1]) {
			cout << "从西面传来了一阵风!\n";
			Sleep(500);
		}
		else if (user.x == Pitfall[i][0] - 1 && user.y == Pitfall[i][1]) {
			cout << "从东面传来了一阵风!\n";
			Sleep(500);
		}
	}
	

}

void Player::ShowPos() {
	cout << "Player{x: " << x << ", y: " << y << ", 剩余弓箭: " << b << "}" << endl;
}

void Umpass::ShowPos() {
	cout << "Umpass{x: " << x << ", y: " << y << "}" << endl;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值