源码
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int blue=100; int HP=1000; int hurt=100; int x=10,y=1; int Boss_HP=2000; int Boss_hurt=200; int Boss_x=10,Boss_y=20; int monsters_HP=200; int monsters_hurt=20; int monsters_x,monsters_y; int hj=0; int fj=0; int money=0; int x_what(int x) {//取随机数 srand((unsigned)time(NULL)); return( rand() % x); } int sc(){ system("cls"); char cz; cout<<"金钱"<=200){ money-=200; fj+=100; } if(cz=='2'&&money>=100){ money-=100; hj+=100; } if(cz=='3'&&money>=100){ money-=100; hurt+=100; } } int open(){ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED| FOREGROUND_GREEN); cout<<" 传奇(DEVC++阳光版)"; cout<<"by:黑客小C"<=100){ blue-=100; HP+=200; if(x==monsters_x&&y==monsters_y-1){ monsters_HP-=(hurt*2); } if(x==Boss_x&&y==Boss_y-1){ Boss_HP-=(hurt*2); } } } if(cz=='q'){ sc(); } } } int main(){ open(); while(true){ out(); play(); if(Boss_HP<=0){ system("cls"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED| FOREGROUND_GREEN); cout<<"游戏胜利"; Sleep(2000); return 0; } if(HP<=0){ system("cls"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED); cout<<"你死了"; Sleep(2000); return 0; } if(monsters_HP<=0){ monsters_HP=200; money+=100; hurt+=100; monsters_x=x_what(18); monsters_x++; monsters_y=x+1; } if(x==monsters_x&&y==monsters_y-1){ HP-=monsters_hurt; HP+=hj; monsters_HP-=fj; } if(x==Boss_x&&y==Boss_y-1){ HP-=Boss_hurt; HP+=hj; Boss_HP-=fj; } blue+=10; Sleep(100); } return 0; }