A simple and easy game

Today, I made a short c++ game, and hope you will like it.

the this that I want to mention is that this game hasn't finish yet,I will make it better as quickly as possible.

Here is the new code:

#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
struct people {
	int ff;
} a[1001];
int f,money=0,attack=10,liehuncnt=1,hp=100,mhp=0,skill[1000001],i=0,shd=0,mattk,waiting,powercnt,killing=0;
string name;
void voids(void);
bool panduan(void);
void Slowsay(string);
void Slowersay(string);
void Slowestsay(string);
void power(void);
void introduction(void);
void battle(void);
void color(string);
void start(void);
string rand_str(const int);
void liehun();
void binjing();
void binfeng();
void lieri();
void huifu();
void battlemonster();
void PVP();
void PVG(int);
void GVG(int,int);
int main();
string member[10001];
//string team[10001]={'fengzi','feng','master','zuanmaster','xiyanghong','leilong','shenying','dazi','shazi','zhaoyu','ruiyunyang','hanyunfei','chengweiming','guiyixi','mixuanheshang','huiseng','runting'};
void GVG(int a,int b) {
	int s1=1,s2=1;
	while(a>=s1) {
		Slowersay("choose your mate ");
		cout<<s1;
		Slowersay("'s name");
		int m;
		cin>>m;
		member[s1]=m;
		s1++;
	}

}
void PVG(int f) {
	color("W");
	Slowersay("LOADING... \n");
	Sleep(100);
	Slowersay("3...\n");
	Sleep(100);
	Slowersay("2...\n");
	Sleep(100);
	Slowersay("1...  START!!\n");
	int t=1;
	while(f>=t) {
		cout<<t<<' ';
		Slowersay("player: ");
		cout<<rand_str(rand()%10)<<endl;
		t++;
	}
	Slowersay("which level do you want to start??\n");
	Slowersay("1.easy.\n");
	Slowersay("2.normal.\n");
	Slowersay("3.hard.\n");
	Slowersay("4.hell.\n");
	Slowersay("5. godlike\n");
	Slowestsay("6. return.\n");
	cin>>f;
	if(f==1) {

	} else if(f==6) {
		introduction();
	}
}
void leitingzhinu() {
	Slowsay("the enemy uses ");
	cout<<"A 级"<<"法术:";
	color("Y");
	Slowsay("雷霆之怒!!");
	color("W");
	Slowsay("your hp-=");
	f=rand()%mattk;
	waiting++;
	hp-=f;
}
void liehun() {
	Slowsay("your hp has improve ");
	f=rand()%20;
	liehuncnt--;
	cout<<f<<"!!"<<endl;
	Slowsay("you also has a nice shield.\n");
	shd++;
	hp+=f;
}
void Slowestsay(string s) {
	for(int i=0; s[i]; i++) {
		cout<<s[i];
		Sleep(50);
	}
}
void battlemonster() {
	Slowestsay("KID,YOU MET A STRONG BOSS!!\n");
}
void binjing() {
	cout<<"--A 级--"<<"法术:";
	color("B");
	cout<<"---冰封术!!---"<<endl;
	Slowsay("You cannot move!!");
	waiting=2;
}
void huifu() {
	cout<<"--S级--"<<"法术:";
	color("G");
	cout<<"----恢复术!!!----"<<endl;
	f=rand()%30;
	hp+=f;
	Slowsay("your hp has improve: ");
	cout<<f<<"!!"<<endl;
}
void binfeng() {
	Slowsay("the enemy uses ");
	cout<<"A 级"<<"法术:";
	color("B");
	cout<<"冰封术!!"<<endl;
	Slowsay("you cannot move!!");
	waiting=2;
}
void liericangqiongyu() {
	Slowsay("the enemy uses ");
	cout<<"A 级"<<"法术:";
	color("R");
	cout<<"烈日苍穹雨!!"<<endl;
	color("W");
	Slowsay("your hp -=");
	f=rand()%(mattk+3);
	cout<<f<<endl;
	hp-=f;
}
void PVP() {
	Slowsay("if you want to start,click 1\n");
	cin>>f;
	if(f==1) {
		Slowersay("LOADING...\n");
		Sleep(250);
		Slowsay("your enemy is called ");
		name=rand_str(rand()%10);
		cout<<name<<endl;
		Slowsay("his hp is ");
		cout<<rand()%(hp*2)<<endl;
		mhp=rand()%(hp*2);
		color("W");
		Sleep(100);
		Slowsay("3..");
		Sleep(100);
		Slowsay("2..");
		Sleep(100);
		Slowsay("1...0!!\n");
		Slowsay("the game starts!!\n");
		power();
	}
}
void continuer() {
	Slowestsay("do you want to continue to fight?? if yes,cin1,else,cin2");
	cin>>f;
	if(f==1) {
		PVP();
	} else if(f==2) {
		start();
	}
}
void power() {
	f=rand()%10;
	mattk=rand()%20;
	mattk=rand()%15;
	if(f>=5) {
		Slowersay("the ememy comes first!!\n");
		f=rand()%10;
		if(f>7) {
			f=rand()%mattk*2;
			if(f>=1 && f<=3) {
				binfeng();
			} else if(f>=4 && f<=7) {
				liericangqiongyu();
			} else if(f>=8 && f<=10) {
				leitingzhinu();
			}
		} else if(f>0 && f<3) {
			Slowersay("the enemy uses ");

			cout<<"B 级"<<"法术:";
			f=rand()%10;
			if(f>=1 && f<=3) {
				color("B");
				cout<<"冰冻术!!"<<endl;
				Slowsay("you cannot move!!\n");
				waiting=1;
			} else if(f>=4 && f<=7) {
				color("R");
				cout<<"豪奔火球!!\n"<<endl;
				color("W");
				Slowsay("your hp -=");
				f=rand()%10;
				cout<<f<<endl;
				hp-=f;
			} else if(f>=8 && f<=10) {
				color("Y");
				Slowsay("雷霆之怒!!\n");
				color("W");
				Slowsay("your hp-=");
				f=rand()%10;
				waiting++;
				hp-=f;
			}
		} else {
			Slowsay("the enemy uses ");
			cout<<"----S 级----"<<"法术:";
			f=rand()%10;
			if(f>=1 && f<=3) {
				color("B");
				cout<<"--冰封万里!!--";
				Slowersay("you cannot move!!\n");
				color("W");
				waiting=4;
				Slowsay("your hp-=");
				f=rand()%12;
				cout<<f<<endl;
				hp-=f;
			} else if(f>=4 && f<=7) {
				color("R");
				cout<<"---三日凌空!!---\n";
				color("W");
				Slowsay("your hp -=");
				f=rand()%15;
				cout<<f<<endl;
				hp-=f;
			} else if(f>=8 && f<=10) {
				color("Y");
				Slowsay("雷霆爆怒!!\n");
				color("W");
				Slowsay("your hp-=");
				f=rand()%(mattk+5);
				waiting++;
				hp-=f;
			}
		}
	} else {
		Slowsay("nice,boy, you came to attack first!!\n");
		if(liehuncnt==1) {
			Slowsay("you uses" );
			cout<<"A级法术:猎魂!!";
			liehun();
		} else {
			Slowersay("you ran to the enemy, and gave him a strict hit!!\n");
			f=rand()%(attack+2);
			mhp-=f;
			Slowsay("his hp has-=");
			cout<<f<<endl;
		}
	}
	while(waiting > 0) {
		Slowsay("sadly,you cannot move know.\n");
		Slowsay("the ememy attack!!\n");
		f=rand()%10;
		hp-=f;
		Slowsay("your hp-=");
		cout<<f<<endl;
		waiting --;
	}
	while(mhp>0 && hp>0) {
		if(mhp<=0) {
			color("G");
			Slowestsay("you win,my boy!!\n");
			f=rand()%70;
			color("W");
			Slowersay("you got ");
			cout<<f;
			Slowersay(" golds!!\n");
			money+=f;
			continuer();
		} else if(hp<=0) {
			color("R");
			Slowestsay("YOU ARE DIED!!!\n QwQ");
			money=0;
			attack=10;
			hp=100;
			introduction();
		}
		f=rand()%5;
		if(f>3) {
			Slowersay("the ememy ran torwards you!!");
			f=rand()%10;
			if(f>=5) {
				Slowersay("he gives a strict punch on you, however,it didn't hit you.\n");
			} else if(f==0) {
				Slowersay("he excaped!!\n");
				color("G");
				Slowestsay("you win,my boy!!\n");
				f=rand()%70;
				color("W");
				Slowersay("you got ");
				cout<<f;
				Slowersay(" golds!!\n");
				money+=f;
				continuer();
			} else {
				Slowersay("you give him a sharp hit!!\n");
				color("W");
				Slowersay("now,his hp has lessen ");
				f=rand()%(attack+2);
				color("R");
				cout<<f<<' ';
				color("W");
				cout<<"!!";
			}
		} else {
			f=rand()%10;
			if(f>=3){
				Slowsay("he give you a sharp shock!!\n");
			f=rand()%(mattk+5);
			Slowsay("your hp has lessen ");
			cout<<f<<"!!"<<endl;
			hp-=f;
			}else if(f==2){
				rand()%10;
				if(f==5){
					binjing();
				}if(f==1){
					liericangqiongyu();
				}else break;
			}
			
		}
	}

}
string rand_str(const int a) {
	string str;
	char c;
	int idx;
	for(idx = 0; idx <a; idx ++) {
		c = 'a' + rand()%26;
		str.push_back(c);
	}
	return str;
}
void Slowsay(string s) {
	for(int i=0; s[i]; i++) {
		cout<<s[i];
		Sleep(10);
	}
}
void Slowersay(string s) {
	for(int i=0; s[i]; i++) {
		cout<<s[i];
		Sleep(15);
	}
}
void color(string i) {
	if(i=="B")SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
	else if(i=="W")SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
	else if(i=="R")SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
	else if(i=="Y")SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
	else if(i=="G")SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
	else if(i=="C")SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
	//else if(i=="MAGENTA");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_R | FOREGROUND_B);
}
void introduction() {
	Slowsay("now, here are some imformation for you to read.\n");
	Slowsay("1.diary\n");
	Slowsay("2.set\n");
	Slowsay("3.start the game\n");
	cin>>f;
	if(f==1) {
		Slowsay("this is the game made by crazyman.\n");
		Slowsay("the game is firstly created in 2022.8.6\n");
		Slowsay("if return, cin:1");
		cin>>f;
		if(f==1) introduction();
	} else if(f==2) {
		Slowsay("change color\n");
		Slowsay("1. WHITE\n");
		Slowsay("2. BLUE\n");
		Slowsay("3. GREEN\n");
		Slowsay("4. return\n");
		cin>>f;
		if(f==1) {
			color("W");
			introduction();
		} else if(f==2) {
			color("B");
			introduction();
		} else if(f==3) {
			color("G");
			introduction();
		} else if(f==4) {
			introduction();
		}
	} else if(f==3) {
		start();
	}
}
void battle() {
	Slowsay("now, you are in a battle, but this battle has already finished an hour ago.\n");
	Slowersay("however,there are still some monsters and enimies around here.\n");
	Slowsay("the ministy wants you to kill all of them.\n");
	Sleep(100);

	Slowsay("Here is a monster in front of you!!\n");
	Slowersay("do you want to go and kill it??\n");
	Slowsay("if yes, cin 1,else,cin 2\n");
	cin>>f;
	if(f==1) {
		Slowsay("the monster's hp is ");
		mhp=rand()%100;
		cout<<mhp<<endl;
		if(liehuncnt>=1) {
			color("R");
			Slowsay("you throw your strongly weapon to the monster!!\n");
			f=rand()%100;
			color("W");
			if(f>=50) {
				Slowersay("you hit the monster!!\n");
				mhp-=attack+10;
				color("Y");
				Slowsay("it's hp is ");
				cout<<mhp<<endl;
				if(mhp<=0) {
					color("G");
					Slowersay("you win!");
					f=rand()%50;
					money+=f;
					Slowersay("you got ");
					cout<<f;
					Slowersay(" of golds,nice try!!\n");
					introduction();
				}
			} else {
				Slowsay("sadly,you didn't hit it.\n");
			}
		} else {
			Slowersay("you ran toword it.\n");
			Slowsay("unfortunatly,the monster hit you first.\n");
			hp-=rand()%10;
			color("W");
			Slowsay("now,your hp is ");
			cout<<hp<<endl;

		}
		while(mhp>0 && hp>0) {
			f=rand()%200;
			if(f>100) {
				color("R");
				Slowersay("ANOTHER ATTACK!\n");
				f=rand()%15;
				mhp-=f;
				color("W");
				Slowsay("you give it another attack, and it's hp has lessen ");
				cout<<f<<endl;
				Slowersay("now,it's hp is");
				cout<<mhp<<endl;
			} else if(f>=10&&f<=20) {
				for(int i=0; i<100; i++) {
					if(skill[i]==1) {
						skill[i]=0;
						f=1;
						break;
					}
				}
				if(f==1) {
					Slowsay("you use your skill!!\n");
					color("G");
					Sleep(20);
					mhp-=5;
					Slowsay("your hp has improve 20,and you have a strong shield\n");
					hp+=20;
					shd++;
				}
			} else {
				Slowersay("it has attacked you!!\n");
				if(shd>0) {
					shd--;
					Slowsay("your shield made the attack disapear!!\n");
				} else {
					int ss=rand()%10;
					hp-=ss;
					Slowsay("you hp-=");
					cout<<ss<<endl;
				}

			}
			if(hp<=0) {
				color("R");
				Slowersay("you are DIED!!!");
				break;
			}
			if(mhp<=0) {
				color("G");
				Slowersay("you win!");
				f=rand()%50;
				money+=f;
				Slowersay("you got ");
				cout<<f;
				Slowersay(" of golds,nice try!!\n");
				introduction();
			}


		}

	}
}
void start() {
	Slowersay("there are many ways to fight.\n");
	Slowersay("1.PVP\n");
	Slowersay("2.PVG\n");
	Slowersay("3.GVG\n");
	Slowersay("4.outfind battle\n");
	Slowersay("5.shop\n");
	Slowsay("which way do you want to choose?\n");
	cin>>f;
	if(f==1) {
		PVP();

	} else if(f==2) {
		Slowsay("attention, boy, you are going to fight with ");
		f=rand()%10;
		cout<<f;
		Slowsay(" people.\n");
		PVG(f);
	} else if(f==3) {
		int f1,f2;
		f1=rand()%10;
		f2=rand()%10;
		GVG(f1,f2);
	} else if(f==4) {
		battle();
	} else if(f==5) {
		Slowsay("you can come and buy some useful weapons or ablilties.\n");
		Slowsay("but they are all very expensive.\n");
		Slowsay("kid,which do you want to buy??\n");
		Slowsay("1.weapon\n");
		Slowsay("2.ability\n");
		cin>>f;
		if(f==1) {
			Slowsay("1. knife\n");
			Slowsay("2. sword\n");
			Slowsay("3. arror\n");
			Slowsay("4. bow\n");
			Slowsay("5.strange water\n");
			cin>>f;
			if(f==1) {
				Slowsay("1.血魔刃\n");
				Slowsay("2.猎手之刀\n");
				Slowsay("3.回首掏刀\n");
				cin>>f;
				if(f==1 && money>=100) {
					Slowersay("you have buy this weapon.\n");
					attack+=10;
					Slowersay("now your attack is:");
					cout<<attack<<endl;
					Slowersay("congradulations!!\n");
					liehuncnt=1;
					introduction();
				} else if(f==1 && money<100) {
					Slowsay("Kid,you didn't bring enough money!\n");
					Slowersay("you can try to kill some of the monsters to improve you money.\n");
					battle();
				} else if(f==2 && money>=150) {
					Slowersay("you have buy this weapon.\n");
					attack+=15;
					Slowersay("now your attack is:");
					cout<<attack<<endl;
					Slowersay("congradulations!!/n");
					Slowersay("you also has a new skill, called:猎魂");
					skill[0]==1;
					liehuncnt=2;
				}

			} else if(f==5) {
				Slowsay("1.恢复药水\n");
				Slowsay("2.剧毒药水\n");
				cin>>f;
				if(f==1) {
					if(money>=50) {
						Slowsay("good,boy!!\n Now your hp is ");
						hp+=20;
						if(hp>100) {
							hp=100;
						}
						cout<<hp<<endl;
						introduction();
					} else {
						Slowsay("boy,your money is too little!!\n");
						Slowsay("however,here is a way for you to improve your money.\n");
						battle();
					}
				}
			}
		} else if(f==2) {
			Slowsay("1.ice\n");
			Slowsay("2.lighting\n");
			Slowsay("3.fire\n");
			cin>>f;
			if(f==1) {
				Slowsay("1.冰晶术\n");
				Slowsay("2.冰封术\n");
				Slowsay("3.冰封百里\n");
				Slowsay("4.冰封千里\n");
				cin>>f;
				if(f==1) {
					if(money>=300) {
						color("B");
						Slowestsay("GOOD!!now you learn a new A level skill!!\n");
					}
				}
			}
		}
	}
}

int main() {
	system("cls");
	srand(time(0));
	color("W");
	Slowsay("This is a game of fight.    ---writer:crazyman\n");
	Slowsay("do you want to start this game? if YES, cin:1\n");
	cin>>f;
	if(f==1) {
		Slowsay("please name yourself.\n");
		cin>>name;
		cout<<"Hello,"<<name<<"!"<<endl;
		introduction();
	}
	return 0;
}

hope you like it (QwQ).

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值