C++小游戏——野外生存

//野外生存1.0.3
//游戏新增:
//1,物品新增:钉子,水箱,子弹...
//BUG修复:
//1,装备武器时BUG
//2,查看状态时BUG
//其他:
#include <iostream>
#include <string>
#include <windows.h>
#include <conio.h>
#include <fstream>
#include <ctime>
#include <time.h>
#include <stdio.h>
#include <sstream>
using namespace std;
struct thing
{
	string type;
	string name;
	int attack;
	int defense;
	int health;
	int num;
	bool disposable;
	int sharp;
	int durability;
};
struct w
{
	string name;
	string b[100];
	int bnum;
};
int health = 1000, maxhealth = 1000, defense = 10, attack = 100;
int capacity = 0;
string name;
int nowway = 0, water = 20110803, maxwater = 20110803;
int bagi = 1, protectlevel;
string protect;
string canmakething[1000] = { "退出","木剑","木斧","木镐","工作台" };
int canmakethingi = 5;
string f[100] = {
	{"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"},
	{"+..................................................................................................+"},
	{"+..................................................................................................+"},
	{"+.........+............................................K...........................................+"},
	{"+.......FV+........................................................................................+"},
	{"+...................F..........T...................................................................+"},
	{"+........+................+.............+.............V.......................CF...................+"},
	{"+.......+..........................................................................................+"},
	{"+.............................................................+.H.+..............B.................+"},
	{"+......F.......+.......+............V............................+.................................+"},
	{"+...............V....+...............................................................Y.............+"},
	{"+....................F+.......+++............++....................................................+"},
	{"+.............................+C+.......o....I+.....o...................S..........F...............+"},
	{"+..........................................+++.....................................................+"},
	{"+.............................+.........................V..........................................+"},
	{"+.........Y...........H......+..........o.......+..A...........+...................................+"},
	{"+...........................+..................o+............++....G..............YV...............+"},
	{"+.....................................................+......+.I...................................+"},
	{"+......................+++.......................+++..........+....................................+"},
	{"+.....................+..U+......................V........+....+.............Y.....................+"},
	{"+.......H...........++...++........................................................................+"},
	{"+.......................+Y................++...................M...................................+"},
	{"+......................................+...G+...........T..........................................+"},
	{"+...H..............W............................................................Y..................+"},
	{"+..................................................................................................+"},
	{"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"},
};
bool isf[100][100];
int movex[4] = { 0,-1,0,1 };
int movey[4] = { -1,0,1,0 };
//H巨坑 I铁矿 C煤矿 G金矿 o小镇 Y城市 V洞穴 S飞船 F战场 M沼泽 T钛矿 P前哨 B硫磺矿 K军事基地
int Outpostx[100], opxi = 0;
int Outposty[100], opyi = 0;
w way[100] = {
	{"池塘",{"进入森林","背包","状态","装备","制作"}, 5},
	{"帮助&设置",{"制造配方"},1}
};
int waynum = 2;
bool isw[100] = { true, false, false };
bool isb[100] = { true, false, false };
thing nowaxe, nowpickaxe, nowweapon, nowhoe;
thing bag[1000] = {
	{"退出","退出",0,0,0,0,false},
};
string outbutton()
{
	char c;
	int now = 0;
	for (int i = 0; i < 100; i++)
	{
		if (isb[i] == true)
		{
			now = i;
		}
	}
	while (1)
	{
		system("cls");
		for (int i = 0; way[i].name != ""; i++)
		{
			if (isw[i] == true)
			{
				cout << "*" << way[i].name << "*";
			}
			else
			{
				cout << " " << way[i].name << " ";
			}
		}
		cout << endl;
		for (int i = 0; way[nowway].b[i] != ""; i++)
		{
			if (isb[i] == true)
			{
				cout << ">" << way[nowway].b[i] << "<" << endl;
			}
			else
			{
				cout << " " << way[nowway].b[i] << " " << endl;
			}
		}
		c = _getch();
		if (c == 'w' && now > 0)
		{
			isb[now] = false;
			isb[now - 1] = true;
			now -= 1;
		}
		if (c == 's' && way[nowway].b[now + 1] != "")
		{
			isb[now] = false;
			isb[now + 1] = true;
			now += 1;
		}
		if (c == 'a' && nowway > 0)
		{
			isw[nowway] = false;
			isw[nowway - 1] = true;
			nowway -= 1;
			isb[now] = false;
			isb[0] = true;
		}
		if (c == 'd' && way[nowway + 1].name != "")
		{
			isw[nowway] = false;
			isw[nowway + 1] = true;
			nowway += 1;
			isb[now] = false;
			isb[0] = true;
		}
		if (c == 32)
		{
			return way[nowway].b[now];
		}
	}
	return "";
}
string outbag()
{
	char c;
	int now = 0;
	bool isbag[1000] = { true, false };
	while (1)
	{
		system("cls");
		for (int i = 0; bag[i].name != ""; i++)
		{
			if (isbag[i] == true)
			{
				cout << ">" << bag[i].name << "<";
			}
			else
			{
				cout << " " << bag[i].name << " ";
			}
			stringstream ss;
			ss << bag[i].num;
			for (int j = 0; j < 20 - bag[i].name.size() - ss.str().size(); j++)
			{
				cout << " ";
			}
			cout << bag[i].num << "    " << bag[i].durability << endl;
		}
		c = _getch();
		if (c == 'w' && now > 0)
		{
			isbag[now] = false;
			isbag[now - 1] = true;
			now -= 1;
		}
		if (c == 's' && bag[now + 1].name != "")
		{
			isbag[now] = false;
			isbag[now + 1] = true;
			now += 1;
		}
		if (c == 32)
		{
			return bag[now].name;
		}
	}
	return 0;
}
bool skills[10];//勘察术 美食家 矿工 收集家 野蛮人 战士 铠甲人 医生 忍者
int fight(string hn, int hmh, int ha, int hd, int hh)
{
	while (1)
	{
		if (nowweapon.type == "剑") cout << "1,扎刺";
		else if (nowweapon.type == "刀") cout << "1,劈砍";
		else if (nowweapon.type == "机枪") cout << "1,扫射";
		else if (nowweapon.type == "手枪") cout << "1,射击";
		else if (nowweapon.type == "") cout << "1,拳击";
		bool is1 = false, is2 = false, is3 = false;
		int i1, i2, i3;
		for (int i = 0; i < 1000; i++)
		{
			if (bag[i].name == "手雷" && bag[i].num != 0)
			{
				cout << " 2,丢出[" << bag[i].num << "]";
				is1 = true;
				i1 = i;
				break;
			}
		}
		for (int i = 0; i < 1000; i++)
		{
			if (bag[i].name == "长矛" && bag[i].num != 0)
			{
				cout << " 3,投掷[" << bag[i].num << "]";
				is2 = true;
				i2 = i;
				break;
			}
		}
		for (int i = 0; i < 1000; i++)
		{
			if (bag[i].name == "熏肉" && bag[i].num != 0)
			{
				cout << " 4,吃肉[" << bag[i].num << "]";
				is3 = true;
				i3 = i;
				break;
			}
		}
		if (skills[7])
		{
			cout << "5,医治";
		}
		string which;
		cin >> which;
		int bullet = 0, missile = 0;
		for (int i = 0; i < 1000; i++)
		{
			if (bag[i].name == "子弹")
			{
				bullet = bag[i].num;
			}
			if (bag[i].name == "导弹")
			{
				missile = bag[i].num;
			}
			else if (bag[i].name == "")
			{
				break;
			}
		}
		if (which == "1")
		{
			if (nowweapon.type == "剑" || nowweapon.type == "刀" || nowweapon.type == "")
			{
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@        E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "] @       E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]  @      E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]   @     E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]    @    E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]     @   E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]      @  E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]       @ E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]        @E[" << hh << "/" << hmh << "]";
				if (skills[5]) hh -= (attack + nowweapon.attack) * 2 - hd;
				else hh -= attack + nowweapon.attack - hd;
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]      @  E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]    @    E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]  @      E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@        E[" << hh << "/" << hmh << "]";
			}
			else if (nowweapon.name == "激光步枪" || bullet > 0 || (nowweapon.name == "火箭筒" && missile > 0))
			{
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@        E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@o       E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@ o      E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@  o     E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@   o    E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@    o   E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@     o  E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@      o E[" << hh << "/" << hmh << "]";
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@       oE[" << hh << "/" << hmh << "]";
				if (skills[5]) hh -= (attack + nowweapon.attack) * 2 - hd;
				else hh -= attack + nowweapon.attack - hd;
				Sleep(10);
				system("cls");
				cout << "\n\n\n\n\n";
				cout << "[" << health << "/" << maxhealth << "]@        E[" << hh << "/" << hmh << "]";
			}
			else if (bullet <= 0 || (nowweapon.name == "火箭筒" && missile <= 0))
			{
				MessageBox(0, TEXT("没弹药了..."), TEXT("重要提示"), MB_OK);
			}
		}
		else if (which == "2" && is1)
		{
			hh -= 500;
			system("cls");
			cout << "砰!";
			Sleep(1000);
			system("cls");
			cout << "[" << health << "/" << maxhealth << "]@        E[" << hh << "/" << hmh << "]";
			bag[i1].num--;
		}
		else if (which == "3" && is2)
		{
			system("cls");
			cout << "\n\n\n\n\n";
			cout << "[" << health << "/" << maxhealth << "]@        E[" << hh << "/" << hmh << "]";
			Sleep(10);
			system("cls");
			cout << "\n\n\n\n\n";
			cout << "[" << health << "/" << maxhealth << "]@>       E[" << hh << "/" << hmh << "]";
			Sleep(10);
			system("cls");
			cout << "\n\n\n\n\n";
			cout << "[" << health << "/" << maxhealth << "]@->      E[" << hh << "/" << hmh << "]";
			Sleep(10);
			system("cls");
			cout << "\n\n\n\n\n";
			cout << "[" << health << "/" << maxhealth << "]@ ->     E[" << hh << "/" << hmh << "]";
			Sleep(10);
			system("
  • 7
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值