最近写了一段迷宫打怪游戏,我想着要有生命值、分数、name(名字),干脆用了类,实际用不用都一样...不要自己改代码,因为里面的x/y坐标是反着的,你们搞不清楚,一改就废
代码(dev-c++运行通过,无报错无警告):
#include<iostream>
#include<cstdio>
#include<time.h>
#include<windows.h>
#include<iomanip>
#include<string>
#include<conio.h>
using namespace std;
class game
{
public:
void setcoin(int c,string n,int r)
{
coin = c;
name = n;
ren = r;
}
void increasecoin()
{
coin += 5;
}
void increaseren()
{
ren -= 5;
}
void print()
{
cout<<endl<<"coin = "<<coin;
cout<<endl<<"name = "<<name<<endl;
cout<<endl<<"生命 = "<<ren;
}
private:
int coin;
string name;
int ren;
};
int main()
{
start:
system("color F0");
/*****地图*****/
char a[1000][1000] = {
"########################################",
"#* # #",
"## $######### ################# ###

这是一个使用C++编写的迷宫打怪游戏,玩家需要控制角色在迷宫中移动,收集金币,击败怪兽。游戏中设有生命值、分数和昵称,玩家需在生命值大于80的情况下击败两个怪兽才能通关。游戏地图以字符串数组表示,玩家通过键盘输入控制角色行动。当玩家达到特定位置时,会触发战斗事件,根据战斗结果调整生命值和分数。游戏结束时会显示玩家的得分和剩余生命值。
最低0.47元/天 解锁文章
592

被折叠的 条评论
为什么被折叠?



