#include <bits/stdc++.h>
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <ctime>
#include <cstdlib>
using namespace std;
char maze[15][35] = {
"###################",
"#O # T #",
"# @ #",
"###################",
};
int sl=0;
int main()
{
int g=10,boss=150,xl=30,sh=1,gj=2,sjsh=0;
int ex = 1;
int ey = 12;
int x = 1, y = 1,j=1;
for(int i=0;i<=99;i++){
Sleep(0.1);
cout<<" 加载中 "<<i<<"%";
system("cls");
}
cout<<" 加载中 "<<99<<"%";
Sleep(5000);
system("cls");
cout<<" 加载中 "<<100<<"%";
Sleep(100);
system("cls");
cout<<endl<<endl<<endl<<" 小学生出品";
Sleep(3000);
system("cls");
char op;
srand(time(0));
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 35; j++) {
cout << maze[i][j] << " ";
}
cout << endl;
}
cout<<endl<<"x=杀,w=上,s=下,a=左,d=右。"<<endl<<"@=怪 T=boss"<<endl<<"怪的血:"<<g<<" boss的血:"<<boss<<endl<<"你的血量:"<<xl<<" 伤害:"<<j;
while(1){
while (true) {
// 主角移动
op = getch();
if (op == 'w' && maze[x-1][y] != '#'&& maze[x-1][y] != '@'&& maze[x-1][y] != 'T') {
maze[x][y] = ' ';
x--;
}
else if (op == 's' && maze[x+1][y] != '#'&& maze[x+1][y] != '@'&& maze[x+1][y] != 'T') {
maze[x][y] = ' ';
x++;
}
else if (op == 'a' && maze[x][y-1] != '#'&& maze[x][y-1] != '@'&& maze[x][y-1] != 'T') {
maze[x][y] = ' ';
y--;
}
else if (op == 'd' && maze[x][y+1] != '#'&& maze[x][y+1] != '@'&& maze[x][y+1] != 'T') {
maze[x][y] = ' ';
y++;
}
else if (op == '1'&&maze[x][y+1] != '@'&& maze[x][y+1] != 'T') {
maze[x][y] = ' ';
y++;
}
else if (op == 'x' ) {
if (maze[x+1][y] == '@'|| maze[x-1][y] == '@'|| maze[x][y+1] == '@'|| maze[x][y-1] == '@') {
sjsh = rand()%8;
if(sjsh>=1){
g-=j;
}
else{
g=g-j*3;
}
xl-=rand()%7;
}
if ( maze[x+1][y] == 'T'|| maze[x-1][y] == 'T'|| maze[x][y+1] == 'T'|| maze[x][y-1] == 'T') {
sjsh = rand()%8;
if(sjsh>=1){
boss-=j;
}
else{
boss=g-j*3;
}
xl-=rand()%50;
}
}
// int eop = rand()%4;
// maze[ex][ey] = ' ';
// if (eop == 0 && maze[ex-1][ey] != '#'&& maze[ex-1][ey] != '$') {
// ex--;
// }
// else if (eop == 1 && maze[ex+1][ey] != '#'&& maze[ex+1][ey] != '$') {
// ex++;
// }
// else if (eop == 2 && maze[ex][ey-1] != '#'&& maze[ex][ey-1] != '$') {
// ey--;
// }
// else if (eop == 3 && maze[ex][ey+1] != '#'&& maze[ex][ey+1] != '$') {
// ey++;
// }
//
// maze[ex][ey] = 'T';
if(g<=0){
g=0;
j+=rand()%10;
g+=gj*10;
xl+=rand()%30;
gj++;
}
if(xl<=0){
system("cls");
break;
}
system("cls");
maze[x][y]='O';
if(boss<=0){
boss=0;
sl=1;
system("cls");
break;
}
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 35; j++) {
cout << maze[i][j] << " ";
}
cout << endl;
}
cout<<endl<<"@=怪 T=boss"<<endl<<"怪的血:"<<g<<" boss的血:"<<boss<<endl<<"你的血量:"<<xl<<" 伤害:"<<j;
}
}
if(sl==1)cout<<endl<<endl<<" 你赢了";
else cout<<endl<<endl<<" 你输了";
Sleep(5000);
return 0;
}
小型打怪游戏2
最新推荐文章于 2024-10-18 22:48:33 发布