大神代码(C++ 游戏)
#include<iostream>
#include<iomanip>
#include<string>
#include<cstring>
#include<stdio.h>
#include<stdlib.h>
#include<windows.h> //Xcode涓嶈兘鐢ㄣ€?
#include<time.h>
#include<unistd.h> //sleep()//1s//usleep()//1/1000000s
#include<cstdlib>//system("cls")
#include<conio.h>//getch()
#define random(x) (rand()%x)
using namespace std;
int lan=0,a[100][100],a2[100][100],a3[100][100],game=0,start=0,move1=0,move2=1,move3=0,e=0,nowx[5],nowy[5],money[5]={10,10,10,10,10},i=0,j=0,fight=0,b=0,p=0,prop[5][11],st[30][2],pstar[5],fn=0,fm=0,f2n=12,f2m=0,win;
int do_you_want_to_open_the_debug=0;
bool debug=0;
char fg[15][15];
double tim;
string DEBUG="TheDEBUG'sKeyIs07543396)&%$##(^TheDEBUG'sKeyIsUndertale_X-tale_Underswap_UnderfellTheDEBUG'sKey3#IsMINECRAFT_MINCERAFT_MC_MC.163.com_1.17_ALPHT_BETA";
struct player{
int m;
int hp;
int arrow;
string bow;
string knife;
};
void SetPos(COORD a)// set cursor
{
HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(out, a);
}
void SetPos(int i, int j)// set cursor
{
COORD pos={i, j};
SetPos(pos);
}
player pp[3];
void outside(string o){
for(int k=0;k<o.length();k++){
cout<<o[k];
usleep(28000);
}
cout<<endl<<endl;
}
void colour(int d){
if(d==1){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_GREEN|
FOREGROUND_BLUE);
}else if(d==2){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |
FOREGROUND_RED);
}else if(d==3){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |
FOREGROUND_GREEN);
}else if(d==4){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED|
FOREGROUND_BLUE);
}else if(d==5){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
}else if(d==6){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_BLUE);
}else if(d==7){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_INTENSITY |
FOREGROUND_RED|FOREGROUND_GREEN);
}else if(d==8){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |BACKGROUND_INTENSITY|FOREGROUND_GREEN|BACKGROUND_RED|
BACKGROUND_BLUE|FOREGROUND_BLUE);
}else if(d==9){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY);
}else if(d==0){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
}else if(d>9&&d<13){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
}else{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY |
FOREGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE);
}
return;
}
void qnn(){
char la;
outside("Select language");
outside("选择语言");
outside("1:English");
outside("2:中文");
la=getch();
lan=la-'0';
cout<<lan<<endl;
if(lan==1){
outside("English selscted");
}else if(lan==2){
outside("已选择中文");
}else{
outside("ERROR");
exit(0);
}
sleep(1);
system("cls");
return;
}
void say(int a){
cout<<endl<<endl<<endl;
if(lan==2){
outside("1会给你三块钱。");
outside("2会扣掉你三块钱。");
outside("3会给你一个随机事件。");
outside("4会给你一个邪恶的转盘。");
outside("5会给你一个好的转盘。");
outside("6会让你和一个人决斗。如果你赢了,你可以拿走那个玩家一半的钱。");
outside("7是星星商家的家,你可以用30元换一个星星。在你买了星星后,星星商人会去地图上的任何地方。一张地图上有30个星星商人。");
outside("8是道具店。(开发中)");
outside("9号是道具供应点。你可以通过经过或停留来获得道具。");
outside("10,11,12,13 分别是玩家 1,2,3,4。");
outside("收集10颗星的玩家就获胜。");
outside("游戏中有10种道具。");
outside("道具1:两倍樱桃。功能:步数乘以2(5块钱)");
outside("道具二:三倍樱桃。功能:步数乘3(10块钱)");
outside("道具三:钱包。功能:给你10元(5元)");
outside("道具四:加速蘑菇。功能:加5步(10元)");
outside("道具5:黄金加速蘑菇。功能:加10步(15元)");
outside("道具六:管道。功能:把你送到地图上的任意位置(15元)");
outside("道具七:金色的管子。功能:传送你到地图上随机星星商人的位置(25元)");
outside("道具八:夹娃娃机。功能:可作为任何道具使用(30元)");
outside("道具9:嘘(boo)。功能:从指定玩家那里偷10块钱,再加35元可以从指定玩家那里偷一颗星星(15块钱)");
outside("道具十:战斗手套。功能:让你和一个指定的玩家战斗,如果你赢了,你可以偷那个玩家的一半钱(15钱)");
outside("按1掷骰子");
outside("按2使用道具");
}else{
outside("1 will give you 3 money ");
outside("2 will clear your 3 money");
outside("3 will give you a random event");
outside("4 will give you an evil turntable");
outside("5 will give you a good turntable");
outside("6 will let you fight any player");
outside("7 is star merchant's home,you can use 30 yuan for a star.After you buy stars, star merchants will go to any place on the map.A map has 30 star merchants");
outside("8 is a props shop");
outside("9 is a prop supply point. You can get a prop by passing or staying");
outside("10,11,12,13 is player 1,2,3,4");
outside("The player who collects 10 stars wins");
outside("There are ten props in the game");
outside("Prop one:double cherry.Function:Steps multiplied by 2(5 money)");
outside("Prop two:triple cherry.Function:Steps multiplied by 3(10 money)");
outside("Prop three:wallet.Function:Give you 10 money(5 money)");
outside("Prop four:sprint mushroom.Function:add 5 steps(10 money)");
outside("Prop five:golden mushroom.Function:add 10 steps(15 money)");
outside("Prop six:pipe.Function:send you to a random location in the map(15 money)");
outside("Prop seven:golden pipe.Function:teleport you to the location of the random star merchant in the map(25 money)");
outside("Prop eight:doll clamping machine.Function:You can use it as any prop(30 money)");
outside("Prop nine:boo.Function:Steal 10 money from the designated player;if you add 35 yuan more, you can steal a star from the designated player(15 money)");
outside("Prop ten:combat gloves.Function:let you fight with a designated player,if you win, you can steal half of that player's money(15 money)");
outside("Press 1 to roll the dice");
outside("Press 2 to use the prop");
}
system("pause");
return;
}
void say2(){
if(lan==2){
outside("Alpha 1.7.2:增加了更新日志。修复了一些bug。");
outside("Alpha 1.8.0:改进了随机事件。修复了一些bug。");
outside("Alpha 1.9.0:添加了好转盘。修复了一些bug。");
outside("Alpha 1.9.2:修复了一些bug。");
outside("Alpha 1.9.3:增加了夹娃娃机。修复了一些bug。");
outside("Alpha 1.9.4:增加了嘘(boo)。修复了一些bug。");
outside("Alpha 1.9.5:修复了一些bug。");
outside("Alpha 1.10.0:增加了战斗1和战斗手套。修复了一些bug。");
outside("Alpha 1.10.1:修复了一些bug。");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
outside("Bata 1.0.0:添加了星星商人。你可以成为这场比赛的赢家!!!");
outside("Beta 1.1.1:修复了一些bug。");
outside("Beta 1.2.0:修复了一些bug。");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
}else{
outside("Alpha 1.7.2:Added update log.Fixed some bugs.");
outside("Alpha 1.8.0:Improved random events.Fixed some bugs.");
outside("Alpha 1.9.0:Added good turntable.Fixed some bugs.");
outside("Alpha 1.9.2:Fixed some bugs.");
outside("Alpha 1.9.3:Added doll clamping machine.Fixed some bugs.");
outside("Alpha 1.9.4:Added boo.Fixed some bugs.");
outside("Alpha 1.9.5:Fixed some bugs.");
outside("Alpha 1.10.0:Added fight 1 and combat gloves.Fixed some bugs.");
outside("Alpha 1.10.1:Fixed some bugs.");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
outside("Bata 1.0.0:Added star merchant.You can be winner in this game!!!");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
outside("Bata 1.1.0:Added shop!You can buy the props!!");
outside("Bata 1.1.1:Fixed some bugs.");
outside("Bata 1.2.0:Fixed some bugs.");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
outside("Bata 1.3.0:Update to 2D!Fixed some bugs.");
}
system("pause");
return;
}
void merchant(int c){
int cc=0,cd=0,cdd=0;
pstar[j]++;
outside("Loading...");
for(int i=0;i<30;i++){
if(st[i][0]==nowx[j]){
cc=i;
break;
}
}
a3[nowx[j]][nowy[j]]=a2[nowx[j]][nowy[j]];
a[nowx[j]][nowy[j]]=a2[nowx[j]][nowy[j]];
a3[cd=(random(100))][cdd=(random(100))]=7;
a[cd][cdd]=7;
return;
}
void begg(int ran,int use){
int give=0;
if(ran>use*25){
outside("Thank you");
outside("I have a prop");
outside("But I can't use it");
outside("So I want to give you!");
sleep(1);
give=(random(10));
switch(give){
case 0:outside("The begger will give you a double cherry");prop[j][0]++;prop[j][10]++;
break;
case 1:outside("The begger will give you a triple cherry");prop[j][1]++;prop[j][10]++;
break;
case 2:outside("The begger will give you a wallet");prop[j][2]++;prop[j][10]++;
break;
case 3:outside("The begger will give you a sprint mushroom");prop[j][3]++;prop[j][10]++;
break;
case 4:outside("The begger will give you a golden mushroom");prop[j][4]++;prop[j][10]++;
break;
case 5:outside("The begger will give you a pipe");prop[j][5]++;prop[j][10]++;
break;
case 6:outside("The begger will give you a golden pipe");prop[j][6]++;prop[j][10]++;
break;
case 7:outside("The begger will give you a doll clamping machine");prop[j][7]++;prop[j][10]++;
break;
case 8:outside("The begger will give you a boo");prop[j][8]++;prop[j][10]++;
break;
case 9:outside("The begger will give you the combat gloves");prop[j][9]++;prop[j][10]++;
break;
}
}else
outside("Sorry.I don't have any props. :(");
return;
}
void event(int player){
int e=0,use=0,ran=0,qqq,qqqq,qqqqq,qn;
e=(random(6));
switch(e){
case 0:outside("Nothing happened");break;
case 1:cout<<"Player "<<j<<" meets a beggar"<<endl;
outside("Press 1 to gives the begger twenty money");
outside("Press 2 to gives the begger ten money");
outside("Press 3 to gives the begger five money");
outside("Press 4 not to give money to beggars");
cin>>use;
ran=(random(100));
switch(use){
case 1:if(money[j]<20){
outside("You don't have enouth money");
break;
}money[j-1]-=20;
begg(ran,use);
break;
case 2:if(money[j]<10){
outside("You don't have enouth money");
break;
}money[j-1]-=10;begg(ran,use);
break;
case 3:if(money[j]<5){
outside("You don't have enouth money");
break;
}money[j]-=5;begg(ran,use);
break;
case 4:outside("QAQ");break;
}
break;
case 2:cout<<"Player "<<j<<" meets a student"<<endl;
outside("Your money -10 because you give a student 10 money");money[j]-=10;break;
case 3:cout<<"Player "<<j<<" going to the park now"<<endl;
outside("Please waiting 20 seconds. :)");
sleep(20);break;
case 4:cout<<"Player "<<j<<" going to the school now"<<endl;
sleep(1);
qqq=(random(10000000));
qqqq=(random(10000000));
cout<<"teacher:"<<qqq<<"+"<<qqqq<<"=? :)"<<endl;
cin>>qqqqq;
if(qqqqq==qqq+qqqq){
outside("GREAT!give you 15 money. :D");
money[j]+=15;break;
}else
outside("NO! (your money-13)");
money[j]-=13;break;
case 5:cout<<"Player "<<j<<"is going to the S* tree."<<endl;
sleep(1);
outside("tree:can you give me 11 money?(1 or 0)");
cin>>qn;
if(qn==1&&money[j]>=11){
outside("tree: thank you.");money[j]-=11;break;
}else
outside("tree: ww... (waiting 40 seconds)");
sleep(40);break;
}
}
void evil(int pl,int &yuan){
int ran=0,w=0;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED | FOREGROUND_BLUE);
outside("clear your 10 money(2/9)");
outside("clear your 20 money(2/9)");
outside("clear your a half of money(2/9)");
outside("clear your a prop(2/9)");
outside("clear your all money(1/18)");
outside("clear your a star(1/18)");
system("pause");
ran=(random(18));
if(ran<4){
yuan-=10;
cout<<"player "<<pl<<"'s ten money has been cleared. :|"<<endl<<endl;
sleep(1);
return;
}else if(ran<8){
yuan-=20;
cout<<"player "<<pl<<"'s twenty money has been cleared. :("<<endl<<endl;
sleep(1);
return;
}else if(ran<12){
yuan/=2;
cout<<"player "<<pl<<"'s half of the money has been cleared. :|"<<endl<<endl;
sleep(1);
return;
}else if(ran<16){
cout<<"player "<<pl<<" will clear a prop. :|"<<endl<<endl;
sleep(1);
w=(random(10));
prop[pl][w]--;
cout<<"The prop "<<w<<" has been removed."<<endl<<endl;
sleep(1);
if(prop[pl][w]<0){
prop[pl][w]++;
outside("But he or she doesn't have the prop. :)");
sleep(1);
}else
prop[pl][10]--;
return;
}else if(ran==16){
yuan=0;
cout<<"player "<<pl<<"'s money has been cleared. X("<<endl<<endl;
sleep(1);
return;
}else
pstar[pl]--;
cout<<"player "<<pl<<"'s star -1. XX("<<endl<<endl;
if(pstar[pl]<0){
pstar[pl]++;
outside("But he or she doesn't have a star. XD");
}
sleep(1);
return;
}
void ppp(){
int ran;
ran=(random(100));
prop[j][10]++;
cout<<"player "<<j<<" get a ";
if(ran<20){
cout<<"double cherry!"<<endl<<endl;//20%
prop[j][0]++;
}else if(ran<40){
cout<<"sprint mushroom!"<<endl<<endl;//20%
prop[j][3]++;
}else if(ran<60){
cout<<"pipe!"<<endl<<endl;//20%
prop[j][5]++;
}else if(ran<70){
cout<<"wallet!"<<endl<<endl;//10%
prop[j][2]++;
}else if(ran<78){
cout<<"triple cherry!!"<<endl<<endl;//8%
prop[j][1]++;
}else if(ran<86){
cout<<"combat gloves!!"<<endl<<endl;//8%
prop[j][9]++;
}else if(ran<91){
cout<<"boo!!"<<endl<<endl;//5%
prop[j][8]++;
}else if(ran<95){
cout<<"golden mushroom!!"<<endl<<endl;//4%
prop[j][4]++;
}else if(ran<98){
cout<<"golden pipe!!!"<<endl<<endl;//3%
prop[j][6]++;
}else
cout<<"doll clamping machine!!!"<<endl<<endl;//2%
prop[j][7]++;
sleep(2);
return;
}
void good(int pl){
int ran=0,w=0;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_RED | FOREGROUND_BLUE|FOREGROUND_GREEN);
outside("give you 10 money(2/9)");
outside("give you 20 money(2/9)");
outside("give you 10~25 money(2/9)");
outside("give you a prop(2/9)");
outside("give you a star(1/9)");
system("pause");
ran=(random(9));
if(ran<2){
cout<<"player "<<pl<<"'s money+10."<<endl;money[j]+=10;sleep(1);return;
}else if(ran<4){
cout<<"player "<<pl<<"'s money+20."<<endl;money[j]+=20;sleep(1);return;
}else if(ran<6){
w=(random(15))+11;
cout<<"player "<<pl<<"'s money+"<<w<<endl;money[j]+=w;sleep(1);return;
}else if(ran<8){
cout<<"player "<<pl<<"'s prop+1."<<endl;ppp();sleep(1);return;
}else
cout<<"player "<<pl<<"'s star+1!!!"<<endl;pstar[j]++;return;
}
void fight1_1b(){
pp[1].arrow--;
if(fn==f2n||fm==f2m){
pp[2].hp--;
}
return;
}
void fight1_2b(){
pp[2].arrow--;
if(fn==f2n||fm==f2m){
pp[1].hp--;
}
return;
}
void fight1_1c(){
if(fg[fn-1][fm]=='2'||fg[fn+1][fm]=='2'||fg[fn][fm-1]=='2'||fg[fn][fm+1]=='2'||fg[fn-1][fm-1]=='2'||fg[fn-1][fm+1]=='2'||fg[fn+1][fm-1]=='2'||fg[fn+1][fm+1]=='2'){
pp[2].hp-=7;
}
}
void fight1_2c(){
if(fg[f2n-1][f2m]=='1'||fg[f2n+1][f2m]=='1'||fg[f2n][f2m-1]=='1'||fg[f2n][f2m+1]=='1'||fg[f2n-1][f2m-1]=='1'||fg[f2n-1][f2m+1]=='1'||fg[f2n+1][f2m-1]=='1'||fg[f2n+1][f2m+1]=='1'){
pp[1].hp-=7;
}
}
void fight1_2(int mo2,int &p1m,int &p2m){
if(mo2=='w'){
if(fn>0&&fg[fn-1][fm]!='2'){
fn--;
fg[fn+1][fm]=' ';
fg[fn][fm]='1';
}
p1m+=(random(5))+1;
return;
}
if(mo2=='s'){
if(fn<12&&fg[fn+1][fm]!='2'){
fn++;
fg[fn-1][fm]=' ';
fg[fn][fm]='1';
}
p1m+=(random(5))+1;
return;
}
if(mo2=='a'){
if(fm>0&&fg[fn][fm-1]!='2'){
fm--;
fg[fn][fm+1]=' ';
fg[fn][fm]='1';
}
p1m+=(random(5))+1;
return;
}
if(mo2=='d'){
if(fm<12&&fg[fn][fm+1]!='2'){
fm++;
fg[fn][fm-1]=' ';
fg[fn][fm]='1';
}
p1m+=(random(5))+1;
return;
}
if(mo2=='8'){
if(f2n>0&&fg[f2n-1][f2m]!='1'){
f2n--;
fg[f2n+1][f2m]=' ';
fg[f2n][f2m]='2';
}
p2m+=(random(5))+1;
return;
}
if(mo2=='5'){
if(f2n<12&&fg[f2n+1][f2m]!='1'){
f2n++;
fg[f2n-1][f2m]=' ';
fg[f2n][f2m]='2';
}
p2m+=(random(5))+1;
return;
}
if(mo2=='4'){
if(f2m>0&&fg[f2n][f2m-1]!='1'){
f2m--;
fg[f2n][f2m+1]=' ';
fg[f2n][f2m]='2';
}
p2m+=(random(5))+1;
return;
}
if(mo2=='6'){
if(f2m<12&&fg[f2n][f2m+1]!='1'){
f2m++;
fg[f2n][f2m-1]=' ';
fg[f2n][f2m]='2';
}
p2m+=(random(5))+1;
return;
}
if(mo2=='q'){
if(p1m>=50&&pp[1].bow=="no"){
p1m-=50;
pp[1].bow="yes";
return;
}
if(pp[1].arrow>=1){
fight1_1b();
}
return;
}
if(mo2=='x'){
if(pp[1].m>=20){
pp[1].arrow+=5;
p1m-=20;
}
return;
}
if(mo2=='7'){
if(p2m>=50&&pp[2].bow=="no"){
p2m-=50;
pp[2].bow="yes";
return;
}
if(pp[2].arrow>=1){
fight1_2b();
}
return;
}
if(mo2=='2'){
if(pp[2].m>=20){
pp[2].arrow+=5;
p2m-=20;
}
return;
}
if(mo2=='e'){
if(p1m>=80&&pp[1].knife=="no"){
p1m-=80;
pp[1].knife="yes";
return;
}
fight1_1c();
}
if(mo2=='9'){
if(p2m>=80&&pp[2].knife=="no"){
p2m-=80;
pp[2].knife="yes";
return;
}
fight1_2c();
}
}
int fight1_1(){
char mo;
for(int i=1;i<=2;i++){
pp[i].hp=100;
pp[i].m=100;
pp[i].arrow=0;
pp[i].bow="no";
pp[i].knife="no";
}
memset(fg,' ',sizeof(fg));
fg[0][0]='1';
fg[13][0]='2';
fn=0;fm=0;f2n=12;f2m=0;
for( ; ; ){
SetPos(0,0);
if(pp[1].hp<=0){
return j;
}
if(pp[2].hp<=0){
return fight;
}
cout<<"# # # # # # # # # # # # # # #| | | | | | | | | | | | | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[0][i]<<" ";cout<<"| | | player 1 | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[1][i]<<" ";cout<<"| | | $:"<<pp[1].m<<" | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[2][i]<<" ";cout<<"| | | hp:"<<pp[1].hp<<" | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[3][i]<<" ";cout<<"| | | arrow:"<<pp[1].arrow<<" | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[4][i]<<" ";cout<<"| | | Bow:"<<pp[1].bow<<" Knife:"<<pp[1].knife<<" | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[5][i]<<" ";cout<<"| | | | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[6][i]<<" ";cout<<"| | | | | | | | | | | | | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[7][i]<<" ";cout<<"| | | player 2 | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[8][i]<<" ";cout<<"| | | $:"<<pp[2].m<<" | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[9][i]<<" ";cout<<"| | | hp:"<<pp[2].hp<<" | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[10][i]<<" ";cout<<"| | | arrow:"<<pp[2].arrow<<" | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[11][i]<<" ";cout<<"| | | Bow:"<<pp[2].bow<<" Knife:"<<pp[2].knife<<" | | |"<<endl;
cout<<"# ";for(int i=0;i<13;i++) cout<<fg[12][i]<<" ";cout<<"| | | | | |"<<endl;
cout<<"# # # # # # # # # # # # # # #| | | | | | | | | | | | | | |"<<endl<<endl<<endl;
mo=getch();
fight1_2(mo,pp[1].m,pp[2].m);
}
return 0;
}
void winnerbyminigamesfight(){
cout<<"Player "<<win<<" won the game!";
cout<<"Time used: "<<(double)clock()/CLOCKS_PER_SEC-tim<<" second!"<<endl<<endl;
sleep(1);
cout<<"You get he or she a half of money!"<<endl<<endl;
if(win==j){
money[j]+=money[fight]/2;
money[fight]/=2;
}else{
money[fight]+=money[j]/2;
money[j]/=2;
}
system("pause");
return;
}
void fight1(){
int e;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |BACKGROUND_INTENSITY|FOREGROUND_GREEN|
FOREGROUND_BLUE|BACKGROUND_RED|BACKGROUND_GREEN);
system("cls");
cout<<"------------C++ good game-----------"<<endl;
outside("Press 1 to start this game.\nPress 2 to view help.");
cin>>e;
if(e==1){
outside("GOGOGO!!!");
tim=(double)clock()/CLOCKS_PER_SEC;
win=fight1_1();
winnerbyminigamesfight();
}else{
outside("1./*map*/");
cout<<"# # # # # # # # # # # # # # #| | | | | | | | | | | | | | |"<<endl;
cout<<"# 1/*player 1*/ #| | | player 1 | | |"<<endl;
cout<<"# #| | /*money*/$:100 | | |"<<endl;
cout<<"# #| | | hp:100 | | |"<<endl;
cout<<"# #| | | arrow:0/*arrow's namber*/|"<<endl;
cout<<"# #| | | Bow:no Knife:no | | |"<<endl;
cout<<"# #| | | | | |"<<endl;
cout<<"# #| | | | | | | | | | | | | | |"<<endl;
cout<<"# #| | | player 2 | | |"<<endl;
cout<<"# #| | | $:100 | | |"<<endl;
cout<<"# #| | | hp:100 | | |"<<endl;
cout<<"# #| | | arrow:0 | | |"<<endl;
cout<<"# #| | | Bow:no Knife:no | | |"<<endl;
cout<<"# 2/*player 2*/ #| | | | | |"<<endl;
cout<<"# # # # # # # # # # # # # # #| | | | | | | | | | | | | | |"<<endl<<endl<<endl;
sleep(5);
outside("2.How to play.");
outside("player 1:\n w:up s:down a:left d:right");
outside(" q:buy or use the bow(50 $ to buy.1 arrow to use)");
outside(" e:buy or use the knife(80 $ to buy)");
outside(" x:buy the arrow(20$ 5 arrow)");
outside("player 2:\n 8:up 5:down 4:left 6:right");
outside(" 7:buy or use the bow(50 $ to buy.1 arrow to use)");
outside(" 9:buy or use the knife(80 $ to buy)");
outside(" 2:buy the arrow(20$ 5 arrow)");
outside("Bow:attack 1 you need use an arrow to use it.\n You and a player in a straight line you can fight it.");
outside("Knife:attack 7.\n You near a player 1M you can fight it.");
outside("every round your $ +1~5");
system("pause");
tim=(double)clock()/CLOCKS_PER_SEC;
win=fight1_1();
winnerbyminigamesfight();
}
return;
}
void fight_(int fgame){
for(;;){
outside("Which player do you want to fight?");
cin>>fight;
if(fight==j){
if(lan==1){
cout<<"You can't fight with you!"<<endl;
}else{
cout<<"你不能和你自己战斗!"<<endl;
}
}else{
break;
}
}
cout<<"Player "<<j<<" will fight player "<<fight;
sleep(1);
fight1();
return;
}
void star(int yy){
outside("HI!Do you want a star?(1 or 0)");sleep(1);
outside("30 money to buy~~~");
cin>>yy;
if(yy==1){
if(money[j]>=30){
outside("Thank you~~~");sleep(1);
outside("The star merchant will go to a random location.");
merchant(yy);
return;
}
outside("You don't have enouth money.");sleep(1);
}
outside("BYE~~~~~~~~~~");
return;
}
void shop(int &yuan){
int e;
outside("HI~~~~,Which prop do you want to buy(You can only buy 1 prop)");
cin>>e;
switch(e){
case 1:if(yuan>=5){
outside("Thank you~~~");
prop[j][0]++;prop[j][10]++;yuan-=5;
break;
}else{
outside("You don't have enouth money.");
break;
}
case 2:if(yuan>=10){
outside("Thank you~~~");
prop[j][1]++;prop[j][10]++;yuan-=10;
break;
}else{
outside("You don'y have enouth money.");
break;
}
case 3:if(yuan>=5){
outside("Thank you~~~");
prop[j][2]++;prop[j][10]++;yuan-=5;
break;
}else{
outside("You don'y have enouth money.");
break;
}
case 4:if(yuan>=10){
outside("Thank you~~~");
prop[j][3]++;prop[j][10]++;yuan-=10;
break;
}else{
outside("You don'y have enouth money.");
break;
}
case 5:if(yuan>=15){
outside("Thank you~~~");
prop[j][4]++;prop[j][10]++;yuan-=15;
break;
}else{
outside("You don'y have enouth money.");
break;
}
case 6:if(yuan>=15){
outside("Thank you~~~");
prop[j][5]++;prop[j][10]++;yuan-=15;
break;
}else{
outside("You don'y have enouth money.");
break;
}
case 7:if(yuan>=25){
outside("Thank you~~~~~~~~~~~~~~~~~~~~");
prop[j][6]++;prop[j][10]++;yuan-=25;
break;
}else{
outside("You don'y have enouth money.");
break;
}
case 8:if(yuan>=30){
outside("Thank you~~~~~~~~~~~~~~~~~~~~~~~~~");
prop[j][7]++;prop[j][10]++;yuan-=30;
break;
}else{
outside("You don'y have enouth money.");
break;
}
case 9:if(yuan>=15){
outside("Thank you~~~");
prop[j][8]++;prop[j][10]++;yuan-=15;
break;
}else{
outside("You don'y have enouth money.");
break;
}
case 10:if(yuan>=15){
outside("Thank you~~~");
prop[j][9]++;prop[j][10]++;yuan-=15;
break;
}else{
outside("You don'y have enouth money.");
break;
}
default:outside("BYE~~~");break;
}
return;
}
bool move4(char go){
if(go=='w'&&nowx[j]-1>=0){
system("cls");
a[nowx[j]][nowy[j]]=a2[nowx[j]][nowy[j]];
nowx[j]--;
a[nowx[j]][nowy[j]]=9+j;
for(int i=-6;i<=6;i++){
for(int k=-6;k<=6;k++){
if(nowx[j]+i<0||nowx[j]+i>=100||nowy[j]+k<0||nowy[j]+k>=100) {
continue;
}
colour(a[nowx[j]+i][nowy[j]+k]);
cout<<std::left<<setw(3)<<a[nowx[j]+i][nowy[j]+k]<<" ";
}
cout<<endl;
}
return false;
}
if(go=='s'&&nowx[j]+1<100){
system("cls");
a[nowx[j]][nowy[j]]=a2[nowx[j]][nowy[j]];
nowx[j]++;
a[nowx[j]][nowy[j]]=9+j;
for(int i=-6;i<=6;i++){
for(int k=-6;k<=6;k++){
if(nowx[j]+i<0||nowx[j]+i>=100||nowy[j]+k<0||nowy[j]+k>=100) {
continue;
}
colour(a[nowx[j]+i][nowy[j]+k]);
cout<<std::left<<setw(3)<<a[nowx[j]+i][nowy[j]+k]<<" ";
}
cout<<endl;
}
return false;
}
if(go=='a'&&nowy[j]-1>=0){
system("cls");
a[nowx[j]][nowy[j]]=a2[nowx[j]][nowy[j]];
nowy[j]--;
a[nowx[j]][nowy[j]]=9+j;
for(int i=-6;i<=6;i++){
for(int k=-6;k<=6;k++){
if(nowx[j]+i<0||nowx[j]+i>=100||nowy[j]+k<0||nowy[j]+k>=100) {
continue;
}
colour(a[nowx[j]+i][nowy[j]+k]);
cout<<std::left<<setw(3)<<a[nowx[j]+i][nowy[j]+k]<<" ";
}
cout<<endl;
}
return false;
}
if(go=='d'&&nowy[j]+1<100){
system("cls");
a[nowx[j]][nowy[j]]=a2[nowx[j]][nowy[j]];
nowy[j]++;
a[nowx[j]][nowy[j]]=9+j;
for(int i=-6;i<=6;i++){
for(int k=-6;k<=6;k++){
if(nowx[j]+i<0||nowx[j]+i>=100||nowy[j]+k<0||nowy[j]+k>=100) {
continue;
}
colour(a[nowx[j]+i][nowy[j]+k]);
cout<<std::left<<setw(3)<<a[nowx[j]+i][nowy[j]+k]<<" ";
}
cout<<endl;
}
return false;
}
return true;
}
void moved(int max){
bool thewrongpress=0;
move1=0;
move1+=(random(4));
move1+=(random(4));
move1+=(random(4));
move1+=1;
move1*=move2;
move1+=move3;
sleep(1);
cout<<"Loading..."<<endl;
sleep(1);
cout<<"Player "<<j<<" can take "<<move1<<" step"<<endl<<endl;
while(move1>=0){
thewrongpress=move4(getch());
SetPos(50,8);
cout<<"You can still walk "<<move1<<" steps"<<endl;
SetPos(63,9);
cout<<"Money"<<endl;
SetPos(60,10);
cout<<"Player 1:"<<money[1]<<endl;
SetPos(60,11);
cout<<"Player 2:"<<money[2]<<endl;
SetPos(60,12);
cout<<"Player 3:"<<money[3]<<endl;
SetPos(60,13);
cout<<"Player 4:"<<money[4]<<endl;
if(!thewrongpress) move1--;
}
colour(0);
sleep(3);
system("pause");
switch(a3[nowx[j]][nowy[j]]){
case 1:cout<<"Player "<<j<<" will add 3 money"<<endl<<endl;money[j]+=3;sleep(2);system("cls");break;
case 2:cout<<"Player "<<j<<" will clean 3 money"<<endl<<endl;money[j]-=3;sleep(2);system("cls");break;
case 3:cout<<"Player "<<j<<" will implement an event"<<endl<<endl;event(j);sleep(2);system("cls");break;
case 4:cout<<"Player "<<j<<" will turn round an evil turntable"<<endl<<endl;evil(j,money[j]);sleep(2);system("cls");break;
case 5:cout<<"Player "<<j<<" will turn round a good turntable"<<endl<<endl;good(j);sleep(2);system("cls");break;
case 6:cout<<"Player "<<j<<" will fight player "<<(random(max))+1<<endl<<endl;fight_(b);sleep(2);system("cls");break;
case 7:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |
FOREGROUND_RED | FOREGROUND_GREEN);cout<<"Player "<<j<<" will going to buy a star!!!"<<endl<<endl;star(b);sleep(3);system("cls");break;
case 8:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
cout<<"Player "<<j<<" will go shopping!"<<endl<<endl;shop(money[j]);sleep(2);system("cls");break;
case 9:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);cout<<"Player "<<j<<" will get a prop"<<endl<<endl;sleep(2),ppp();system("cls");break;
default:cout<<"HaHa"<<endl<<endl;sleep(2);system("cls");break;
}
move2=1;
move3=0;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
return;
}
void boo(){
int p,s;
outside("Which player do you want to steal?");
cin>>p;
if(money[p]>=10){
if(money[j]>=45&&pstar[p]>0){
outside("Do you want to steal he or she a star?(money-35)(1 or 0)");
cin>>s;
if(s>0){
outside("OK!");
money[j]-=35;
pstar[p]--;pstar[j]++;
prop[j][8]--;prop[j][10]--;
return;
}else
outside("OK!");
sleep(1);
}
outside("You steal 10 money for he or she.");
prop[j][8]--;prop[j][10]--;
}else
outside("He or she don't have 10 money");
boo();
return;
}
void dcm(){
int p;
outside("Which prop do you want to use");
cin>>p;
outside("props used");
switch(p){
int going;
case 1:move2=2;moved(b);break;
case 2:move2=3;moved(b);break;
case 3:money[j]+=10;moved(b);break;
case 4:move3+=5;moved(b);break;
case 5:move3+=10;moved(b);break;
case 6:nowx[j]=(random(100));nowy[j]=(random(100));moved(b);break;
case 7:nowx[j]=st[going=(random(30))][0];nowy[j]=st[going][1];prop[j][10]--;prop[j][6]--;moved(b);break;
case 8:outside("Prohibited use!");dcm();break;
case 9:boo();moved(b);break;
case 10:fight_(b);prop[j][10]--;prop[j][9]--;moved(b);break;
}
}
int main(){
//qnn();
int m,m2,ran,ran2,s=0;
char mm,mm2,ee;
memset(nowx,0,sizeof(nowx));
memset(nowy,0,sizeof(nowy));
memset(prop,0,sizeof(prop));
memset(pstar,0,sizeof(pstar));
memset(fg,' ',sizeof(fg));
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(lan==1){
cout<<"------------big rich man-------------"<<endl;
}else{
cout<<"---------------大富翁----------------"<<endl;
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |FOREGROUND_BLUE|FOREGROUND_GREEN);
cout<<" \\\\ Bata 1.3.0 // "<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(lan==1){
cout<<"--please type your number of player--"<<endl;
}else{
cout<<"--------请输入你们的玩家数-----------"<<endl;
}
cout<<" (2~4)"<<endl;
mm=getch();
m=mm-'0';
if(m<2){
m=2;
}
if(m>4){
m=4;
}
if(mm=='X'){
do_you_want_to_open_the_debug+=1;
}
cout<<m<<endl;
if(lan==1){
cout<<"-------Press one to view help--------"<<endl;
cout<<"-----Press two don't to view help----"<<endl;
cout<<"----Press three to view update log---"<<endl;
}else{
cout<<"-------------按1查看帮助-------------"<<endl;
cout<<"------------按2不查看帮助------------"<<endl;
cout<<"-----------按3查看更新日志-----------"<<endl;
}
mm2=getch();
m2=mm2-48;
cout<<m2<<endl;
if(lan==2){
cout<<" 开始 "<<endl;
cout<<"小贴士:按h查看帮助。"<<endl;//h=88
}else{
cout<<" GO "<<endl;
cout<<"Tip:Press 'h' to view help"<<endl;
}
if(mm2=='#'){
do_you_want_to_open_the_debug+=1;
}
if(do_you_want_to_open_the_debug==2){
outside("Please press enter.");
string mm3;
getline(cin,mm3);
if(mm3=="I know what am I doing.I want to open the debug."){
outside("Ok.Please input the password.");
cin>>mm3;
if(mm3==DEBUG){
outside("DEBUG is open.");
debug=true;
}else{
outside("ERROR!");
sleep(1);
for(char a=0;;a++){
cout<<a;
}
}
}
}
sleep(3);
cout<<endl;
srand((int)time(0));
int countbymap=0;
system("cls");
for(i=0;i<100;i++){
for(int j=0;j<100;j++){
ran=(random(100));
if(ran<40){//40%
a[i][j]=1;
}else if(ran<70){//30%
a[i][j]=2;
}else if(ran<87){//17%
a[i][j]=3;
}else if(ran<92){//5%
a[i][j]=4;
}else if(ran<97){//5%
a[i][j]=5;
}else if(ran<99){//2%
a[i][j]=6;
}else{a[i][j]=0;}//1%
a2[i][j]=a[i][j];
a3[i][j]=a[i][j];
countbymap++;
SetPos(0,0);
if(lan==2){
cout<<countbymap<<"/10000 加载中..."<<endl;
}else{
cout<<countbymap<<"/10000 loading..."<<endl;
}
usleep(10);
}
}
system("cls");
if(m2==1){
say(b);
}else if(m2==3){
say2();
}
if(lan==2){
cout<<"加载中..."<<endl;
}else{
cout<<"loading..."<<endl;
}
sleep(3);
for(int i=0;i<200;i++){
ran=(random(100));
ran2=(random(100));
a[ran][ran2]=9;
a2[ran][ran2]=9;
a3[ran][ran2]=9;
}
for(int i=0;i<150;i++){
ran=(random(100));
ran2=(random(100));
a[ran][ran2]=8;
a2[ran][ran2]=8;
a3[ran][ran2]=8;
}
for(int i=0;i<30;i++){
ran=(random(100));
ran2=(random(100));
a[ran][ran2]=7;
a3[ran][ran2]=7;
}
system("cls");
for(int i=0;i<100;i++){
for(int j=0;j<100;j++){
colour(a[i][j]);
cout<<a[i][j]<<" ";
if(a[i][j]==7){
st[s][0]=i;
st[s][1]=j;
s++;
}
}
}
;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY |FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE
|FOREGROUND_INTENSITY);
system("pause");
system("cls");
game=0;
fg[fn][fm]='1';
fg[f2n][f2m]='2';
for(int i=1;game!=32767;i++){
if(lan==1) cout<<"Turn "<<i<<endl;
else cout<<"第"<<i<<"轮"<<endl;
for(j=1;j<=m;j++){
if(money[j]<0){
money[j]=0;
}
cout<<"Now it's player "<<j<<"'s turn"<<endl;
string debug2;
if(debug){
getline(cin,debug2);
}
ee=getch();
e=ee-'0';
cout<<e<<endl;
if((e>2||e<1)&&!debug){
outside("ERROR");
outside("Auto adjust to dice");
moved(m);
}
if(e==1){
moved(m);
}
if(e==2){
if(prop[j][10]==0){
cout<<"error!!!"<<endl;
outside("You have to have a prop");
sleep(3);
outside("Auto adjust to dice");
moved(b);
break;
}else
outside("Which prop do you want to use");
cin>>p;
if(prop[j][p-1]==0){
cout<<"error!!!"<<endl;
outside("You have to have this prop");
sleep(3);
outside("Auto adjust to dice");
moved(m);
break;
}else
outside("props used");
switch(p){
int going;
case 1:move2=2;prop[j][10]--;prop[j][0]--;moved(b);break;
case 2:move2=3;prop[j][10]--;prop[j][1]--;moved(b);break;
case 3:money[j]+=10;prop[j][10]--;prop[j][2]--;moved(b);break;
case 4:move3+=5;prop[j][10]--;prop[j][3]--;moved(b);break;
case 5:move3+=10;prop[j][10]--;prop[j][4]--;moved(b);break;
case 6:nowx[j]=(random(100));nowy[j]=(random(100));moved(b);break;
case 7:nowx[j]=st[going=(random(30))][0];nowy[j]=st[going][1];prop[j][10]--;prop[j][6]--;moved(b);break;
case 8:dcm();prop[j][10]--;prop[j][7]--;moved(b);break;
case 9:boo();moved(b);break;
case 10:fight_(b);prop[j][10]--;prop[j][9]--;moved(b);break;
}
}
if(debug){
int inputmoney=0;
if(debug2=="stop"){
game=32767;
}
if(debug2=="P1's money++"){
outside("Input number.");
cin>>inputmoney;
money[1]+=inputmoney;
}
if(debug2=="P2's money++"){
outside("Input number.");
cin>>inputmoney;
money[2]+=inputmoney;
}
if(debug2=="P3's money++"){
outside("Input number.");
cin>>inputmoney;
money[3]+=inputmoney;
}
if(debug2=="P4's money++"){
outside("Input number.");
cin>>inputmoney;
money[4]+=inputmoney;
}
}
if(pstar[j]>=10){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY |
FOREGROUND_RED | FOREGROUND_GREEN);
if(lan==1){ cout<<"PLAYER ";sleep(1);cout<<j;sleep(1);cout<<" WIN!!!"<<endl<<endl;sleep(1);}
else cout<<"玩家";sleep(1);cout<<j;sleep(1);cout<<"获胜!!!"<<endl<<endl;sleep(1);
return 0;
}
}
}
}