Dev-C++手写平面起床战争可运行(彩色)

提示:运行出来可能有些地方大家看不懂,这里解释一下:

  1. (Wa)这个的意思是挖掘
  2. (Fang)这个意思是放置方块(手里由羊毛的前提下)
  3. 有一个表,如下图,他是一个物品购买对照表,第一排是物品编号,第二排是物品,分别是(羊毛,铁剑,钻石剑,下界合金剑,铁套,钻石套,下界合金套,金苹果,附魔金苹果),第三排是价格,第四排是对应的技能,比如剑,就是伤害;比如盔甲(也就是...套),就是防御,比如苹果,就是回血量
  4. 最后就是奉上代码,很累的,点个赞吧,谢谢!(此代码纯自创)

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<stdio.h>
#include<windows.h>
#include<conio.h>
#define random(x) (rand()%x)
using namespace std;
char s[1010][1010] = { 
{"#################################"},
{"#........        .......       .#"},
{"#.. @  ...   @      .....   @ ..#"},
{"#... ....................... ...#"},
{"#..     ......        ....     h#"},
{"#    #  .....  # # #  ....      #"},
{"#[R  #  .....  #      .... #  H]#"},
{"#       .....  #  #  #....      #"},
{"#.r.... .....    @    .... .....#"},
{"#.....   ....  #   #  ...  .....#"},
{"#.....    ...         ... @  ...#"},
{"#....  @   ...  #   # ...   ....#"},
{"#.....    ......................#"}, 
{"#################################"}};
char mp[1010][1010] = { 
{"#################################"},
{"#........        .......       .#"},
{"#.. @  ...   @      .....   @ ..#"},
{"#... ....................... ...#"},
{"#..     ......        ....     h#"},
{"#    #  .....  # # #  ....      #"},
{"# R  #  .....  #      .... #@ H]#"},
{"#       .....  #  #  #....      #"},
{"#...... .....    @    .... .....#"},
{"#.....   ....  #   #  ...  .....#"},
{"#.....    ...         ... @  ...#"},
{"#....  @   ...  #   # ...   ....#"},
{"#.....    ......................#"}, 
{"#################################"}};
//2 1
//12 28
//8 2
//4 31
/*
   1   2   3   4   5   6   7   8   9
  ym  tj  zj  xj  tt  zt  xt  jpp fjpp
 4*8  40  60  80  78  90  120  50  60
      7   10  16  5   8   12   5   8
*/ 
struct oi{
	int wopin;
	int jiage;
}a[10];
struct beibao{
	int wpin;
	int shuliang;
}rb[100], hb[100];
bool shifoukaishi = false;
int duoshaobule = 0;
//150;
int rrl = 0;
int rrw = 0;
int hrl = 0;
int hrw = 0;
int hh = 0;
int rh = 0;
int hz = 0;
int rz = 0;
bool c=true;
bool r=true;
int rx=6, ry=2, cx=6, cy=30;
int xr = 20, xc = 20;
int n=14, m=33;
int jr=0, jc=0;
string jyt1;
int jyt2[30] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
int jl[10], js = 0;
int jx[10] = {1, 2, 2, 8, 10, 11};
int jy[10] = {27, 4, 13, 17, 26, 7};

void shuchu(){

//         w(up)
// a(laft) s(down) d(rigth)
//q(Press q next to @ to add experience)
//1() 2() 3() 4()
//z() x() c() v() 
//`() f() r() t()


	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
	cout << "w(shang) a(zuo) s(xia) d(you)\n\
q(JingYan) 1(WaShang) 2(WaXia) 3(WaZuo) 4(WaYou)\n\
z(FangShang) x(FangXia) c(FangZuo) v(FangYou) `(ShiYong) f(QieHuanShangDian) r(GouMai) t(QieHuanWuPin)\n";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout << "↑(shang) ←(zuo) ↓(xia) →(you)\n\
\'(JingYan) 9(WaShang) 0(WaXia) -(WaZuo) =(WaYou)\n\
m(FangShang) ,(FangXia) .(FangZuo) /(FangYou) \\(ShiYong) l(QieHuanShangDian) ;(GouMai) ](QieHuanWuPin)\n";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
	cout << "\
   1   2   3   4   5   6   7   8   9\n\
  ym  tj  zj  xj  tt  zt  xt  jpp fjpp\n\
 4*8  40  60  80  78  90  120  50  60\n\
      7   10  16  5   8   12   5   8\n";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
	cout << "Ruined xue :\t" << xr; 
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout << "\tHasnot xue :\t" << xc;
	cout << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
	cout << "Ruined jing:\t" << jr;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout << "\tHasnot jing:\t" << jc;
	cout << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
	cout << "Ruined kui :\t" << rh;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout << "\tHasnot kui :\t" << hh;
	cout << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
	cout << "Ruined gong:\t" << rz;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout << "\tHasnot gong:\t" << hz;
	cout << endl;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			if(s[i][j]=='#')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
				cout << "#";
			}
			if(s[i][j]=='.')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
				cout << ".";
			}
			if(s[i][j]=='R'||s[i][j]=='[')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
				cout << s[i][j];
			}
			if(s[i][j]=='H'||s[i][j]==']')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | (FOREGROUND_RED |FOREGROUND_GREEN)|FOREGROUND_RED);
				cout << s[i][j];
			}
			if(s[i][j]=='*')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN |FOREGROUND_BLUE);
				cout << s[i][j];
			}
			if(s[i][j]=='+')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
				cout << "+";
			}
			if(s[i][j]=='N')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN | FOREGROUND_BLUE);
				cout << "N";
			}
			if(s[i][j]==' ')
			{
				cout << " ";
			}
			if(s[i][j]=='@')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
				cout << s[i][j];
			}
			if(s[i][j]=='r'||s[i][j]=='h'||(s[i][j] >= '1'&&s[i][j]<='9')) {
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN |FOREGROUND_BLUE);
				cout << s[i][j];
			}
		}
		cout << endl;
	}
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
	for(int i = 1; i <= rrl; i++)
	{
		if(i==rrw) cout << "(" << rb[i].wpin << "," << rb[i].shuliang << ")";
		else cout << "[" << rb[i].wpin << "," << rb[i].shuliang << "]";
	}
	cout << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | (FOREGROUND_RED |FOREGROUND_GREEN));
	for(int i = 1; i <= hrl; i++)
	{
		if(i==hrw) cout << "(" << hb[i].wpin << "," << hb[i].shuliang << ")";
		else cout << "[" << hb[i].wpin << "," << hb[i].shuliang << "]";
	}
}
void shuchu1(){

//         w(up)
// a(laft) s(down) d(rigth)
//q(Press q next to @ to add experience)
//1() 2() 3() 4()
//z() x() c() v() 
//`() f() r() t()

	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout << "↑(shang) ←(zuo) ↓(xia) →(you)\n\
\'(JingYan) 9(WaShang) 0(WaXia) -(WaZuo) =(WaYou)\n\
m(FangShang) ,(FangXia) .(FangZuo) /(FangYou) \\(ShiYong) l(QieHuanShangDian) ;(GouMai) ](QieHuanWuPin)\n";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
	cout << "\
   1   2   3   4   5   6   7   8   9\n\
  ym  tj  zj  xj  tt  zt  xt  jpp fjpp\n\
 4*8  40  60  80  78  90  120  50  60\n\
      7   10  16  5   8   12   5   8\n";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
	cout << "Ruined xue :\t" << xr; 
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout << "\tHasnot xue :\t" << xc;
	cout << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
	cout << "Ruined jing:\t" << "Max";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout << "\tHasnot jing:\t" << jc;
	cout << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
	cout << "Ruined kui :\t" << 8;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout << "\tHasnot kui :\t" << hh;
	cout << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
	cout << "Ruined gong:\t" << 16;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
	cout << "\tHasnot gong:\t" << hz;
	cout << endl;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			if(mp[i][j]=='#')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
				cout << "#";
			}
			if(mp[i][j]=='.')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
				cout << ".";
			}
			if(mp[i][j]=='R'||mp[i][j]=='[')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
				cout << mp[i][j];
			}
			if(mp[i][j]=='H'||mp[i][j]==']')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | (FOREGROUND_RED |FOREGROUND_GREEN)|FOREGROUND_RED);
				cout << mp[i][j];
			}
			if(mp[i][j]=='*')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN |FOREGROUND_BLUE);
				cout << mp[i][j];
			}
			if(mp[i][j]=='+')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
				cout << "+";
			}
			if(mp[i][j]=='N')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN | FOREGROUND_BLUE);
				cout << "N";
			}
			if(mp[i][j]==' ')
			{
				cout << " ";
			}
			if(mp[i][j]=='@')
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
				cout << mp[i][j];
			}
			if(mp[i][j]=='r'||mp[i][j]=='h'||(mp[i][j] >= '1'&&mp[i][j]<='9')) {
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN |FOREGROUND_BLUE);
				cout << mp[i][j];
			}
		}
		cout << endl;
	}
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | (FOREGROUND_RED |FOREGROUND_GREEN));
	for(int i = 1; i <= hrl; i++)
	{
		if(i==hrw) cout << "(" << hb[i].wpin << "," << hb[i].shuliang << ")";
		else cout << "[" << hb[i].wpin << "," << hb[i].shuliang << "]";
	}
}
//bool opq()
//{
//	if(s[rx][ry]=='.')
//	{
//		return true;
//	}
//	if(s[cx][xy]=='.')
//	{
//		return true;
//	}
//	return false;
//}
void choujian(){
	srand(time(0));
	int t = rand()%10;
	Sleep(1000);
	int k = rand()%10;
	cout << "3";
	Sleep(1300);
	cout << "\r2";
	Sleep(1300);
	cout << "\r1";
	cout << "\r";
	cout << t << "        " << k;
	int u = 0;
	while(u==t||u==k)
	{
		u = _getch();
	}
	if(u==t)
	{
		r=true;
	}
	if(u==c)
	{
		c=true;
	}
	return ;
}void xvanze_1() {
	system("cls");
	cout << endl << endl << endl << endl << endl << endl << endl << endl << endl; 
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_BLUE);
	cout << "                                                   上'W'下'S'" << endl << endl << endl << endl; 
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_GREEN);
	cout << "                                                  绿";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_BLUE);
	cout << "色为选中" << endl << endl << endl << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_GREEN);
	cout << "                                                 ________________" << endl;
	cout << "                                                /                \\" << endl;
	cout << "                                               |  ShuangRenYouXi  |" << endl;
	cout << "                                                \\________________/" << endl << endl << endl << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_BLUE);
	cout << "                                                 ________________" << endl;
	cout << "                                                /                \\" << endl;
	cout << "                                               |    DanRenYouXi   |" << endl;
	cout << "                                                \\________________/" << endl << endl << endl << endl;
}void xvanze_2() {
	system("cls");
	cout << endl << endl << endl << endl << endl << endl << endl << endl << endl; 
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_BLUE);
	cout << "                                                   上'W'下'S'" << endl << endl << endl << endl; 
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_GREEN);
	cout << "                                                  绿";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_BLUE);
	cout << "色为选中" << endl << endl << endl << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_BLUE);
	cout << "                                                 ________________" << endl;
	cout << "                                                /                \\" << endl;
	cout << "                                               |  ShuangRenYouXi  |" << endl;
	cout << "                                                \\________________/" << endl << endl << endl << endl;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY |FOREGROUND_GREEN);
	cout << "                                                 ________________" << endl;
	cout << "                                                /                \\" << endl;
	cout << "                                               |    DanRenYouXi   |" << endl;
	cout << "                                                \\________________/" << endl << endl << endl << endl;
}
int fangxiangh(int x1, int y1, int x2, int y2)
{
	srand(time(NULL));
	if(x1 < x2) {
		if(y1 == y2) {
			//cout << "1 ";
			return 2;
		} if(y1 > y2) {
			//zuoxia
			if((y1 - y2) < (x2 - x1)) {
				//cout << "2 ";
				return 2;
			} else if((y1 - y2) == (x2 - x1)) {
				int FF = rand() % 2;
				if(FF == 0) {
					//cout << "
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值