Skip to content

Commit

Permalink
fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Realself-Ma committed Jun 28, 2020
1 parent b3b33e4 commit 9a62b3f
Show file tree
Hide file tree
Showing 75 changed files with 67 additions and 35 deletions.
32 changes: 25 additions & 7 deletions Dungeon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Dungeon::Dungeon(QWidget *parent): QWidget(parent)
initialFogArr();
initialMapString();
initialMonsterPic();
initialCmptorPic();
initialrole();
initialenemy();

Expand Down Expand Up @@ -176,7 +177,24 @@ void Dungeon::initialMonsterPic()
MonsterPic[5]="border-image: url(:/info/image/information/红色食人花.png);";
MonsterPic[6]="border-image: url(:/info/image/information/飞行鸭.png);";
}

void Dungeon::initialCmptorPic()
{
for(int i=0;i<4;++i)
{
for(int j=0;j<4;++j)
{
if(i==0||i==1)
{
CmptorPic[i][j]=QString("border-image: url(:/Cmptor/image/Cmptor/")+
QString::number(i)+QString(".png);");
break;
}
else
CmptorPic[i][j]=QString("border-image: url(:/Cmptor/image/Cmptor/")+
QString::number(i)+"/"+QString::number(i)+QString::number(j)+QString(".png);");
}
}
}
int Dungeon::pk(struct Monster & m)
{
//计算伤害值,-1表示打不动对方防御,-2表示双方都打不动对方防御
Expand Down Expand Up @@ -1178,7 +1196,7 @@ void Dungeon::pkStart()
surface->sign->roomWidget->chatRoom->cur_x=10;
surface->sign->roomWidget->chatRoom->cur_y=14;
gLayout_Map->addWidget(competitor,10,14);
competitor->setStyleSheet(DungeonStytle[3][0]);
competitor->setStyleSheet(CmptorPic[1][0]);
competitor->show();
}
else
Expand All @@ -1188,7 +1206,7 @@ void Dungeon::pkStart()
surface->sign->roomWidget->chatRoom->cur_x=1;
surface->sign->roomWidget->chatRoom->cur_y=1;
gLayout_Map->addWidget(competitor,1,1);
competitor->setStyleSheet(DungeonStytle[3][0]);
competitor->setStyleSheet(CmptorPic[1][0]);
competitor->show();
}
surface->sign->roomWidget->chatRoom->udpkStatusRequest(role.hp,role.atk,role.def);
Expand Down Expand Up @@ -1267,7 +1285,7 @@ void Dungeon::pkMapUpdate()
map[floor-1][cur_x][cur_y]=1;
MazeWidget[cur_x][cur_y]->setStyleSheet(DungeonStytle[1][0]);
gLayout_Map->addWidget(competitor,cur_x,cur_y);
competitor->setStyleSheet(DungeonStytle[2][0]);
competitor->setStyleSheet(CmptorPic[0][0]);
}
}
else
Expand All @@ -1287,7 +1305,7 @@ void Dungeon::pkMapUpdate()
map[floor-1][cur_x][cur_y]=1;
MazeWidget[cur_x][cur_y]->setStyleSheet(DungeonStytle[1][0]);
gLayout_Map->addWidget(competitor,cur_x,cur_y);
competitor->setStyleSheet(DungeonStytle[3][0]);
competitor->setStyleSheet(CmptorPic[1][0]);
}
}
else
Expand All @@ -1307,7 +1325,7 @@ void Dungeon::pkMapUpdate()
map[floor-1][cur_x][cur_y]=1;
MazeWidget[cur_x][cur_y]->setStyleSheet(DungeonStytle[1][0]);
gLayout_Map->addWidget(competitor,cur_x,cur_y);
competitor->setStyleSheet(DungeonStytle[4][moveNum++%4]);
competitor->setStyleSheet(CmptorPic[2][moveNum++%4]);
}
}
else
Expand All @@ -1327,7 +1345,7 @@ void Dungeon::pkMapUpdate()
map[floor-1][cur_x][cur_y]=1;
MazeWidget[cur_x][cur_y]->setStyleSheet(DungeonStytle[1][0]);
gLayout_Map->addWidget(competitor,cur_x,cur_y);
competitor->setStyleSheet(DungeonStytle[5][moveNum++%4]);
competitor->setStyleSheet(CmptorPic[3][moveNum++%4]);
}
}
else
Expand Down
2 changes: 2 additions & 0 deletions Dungeon.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Dungeon: public QWidget
void setCharacterPos(int floor,int target);
void initialMapString();
void initialMonsterPic();//初始化怪物图片(用于战斗界面)
void initialCmptorPic();
void initialrole();
void initialenemy();
void initialFogArr();
Expand Down Expand Up @@ -182,6 +183,7 @@ private slots:
Monster enemy[10];
QString DungeonStytle[41][4];
QString MonsterPic[20];//怪物图片字符串
QString CmptorPic[4][4];
int floor;
int x;//角色位置
int y;
Expand Down
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified datum/1.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified datum/10.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified datum/11.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified datum/2.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified datum/3.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified datum/4.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified datum/5.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified datum/6.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified datum/7.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified datum/8.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified datum/9.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/Cmptor/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/Cmptor/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/Cmptor/2/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/Cmptor/2/21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/Cmptor/2/22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/Cmptor/2/23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/Cmptor/3/30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/Cmptor/3/31.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/Cmptor/3/32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/Cmptor/3/33.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/Dungeon/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/Dungeon/14/140.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/Dungeon/14/141.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/Dungeon/14/142.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/Dungeon/14/143.png
Binary file modified image/Dungeon/15/150.png
Binary file modified image/Dungeon/15/151.png
Binary file modified image/Dungeon/15/152.png
Binary file modified image/Dungeon/15/153.png
Binary file modified image/Dungeon/16/160.png
Binary file modified image/Dungeon/16/161.png
Binary file modified image/Dungeon/16/162.png
Binary file modified image/Dungeon/16/163.png
Binary file modified image/Dungeon/18/180.png
Binary file modified image/Dungeon/18/181.png
Binary file modified image/Dungeon/18/182.png
Binary file modified image/Dungeon/18/183.png
Binary file modified image/Dungeon/19/190.png
Binary file modified image/Dungeon/19/191.png
Binary file modified image/Dungeon/19/192.png
Binary file modified image/Dungeon/19/193.png
Binary file modified image/Dungeon/20/200.png
Binary file modified image/Dungeon/20/201.png
Binary file modified image/Dungeon/20/202.png
Binary file modified image/Dungeon/20/203.png
Binary file modified image/Dungeon/21/210.png
Binary file modified image/Dungeon/21/211.png
Binary file modified image/Dungeon/21/212.png
Binary file modified image/Dungeon/21/213.png
Binary file modified image/Dungeon/22/220.png
Binary file modified image/Dungeon/22/221.png
Binary file modified image/Dungeon/22/222.png
Binary file modified image/Dungeon/22/223.png
Binary file modified image/Dungeon/23.png
Binary file modified image/Dungeon/24.png
Binary file modified image/Dungeon/25.png
Binary file modified image/Dungeon/26.png
Binary file modified image/Dungeon/27.png
Binary file modified image/Dungeon/28.png
Binary file modified image/Dungeon/29.png
Binary file modified image/Dungeon/30.png
Binary file modified image/Dungeon/31.png
Binary file modified image/Dungeon/32.png
Binary file modified image/Dungeon/6.png
Binary file modified image/Dungeon/7.png
46 changes: 29 additions & 17 deletions sources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@
<file>image/Dungeon/23.png</file>
<file>image/Dungeon/24.png</file>
<file>image/Dungeon/25.png</file>
<file>image/Dungeon/26.png</file>
<file>image/Dungeon/27.png</file>
<file>image/Dungeon/28.png</file>
<file>image/Dungeon/29.png</file>
<file>image/Dungeon/30.png</file>
<file>image/Dungeon/31.png</file>
<file>image/Dungeon/32.png</file>
<file>image/Dungeon/dead.png</file>
<file>image/Dungeon/fog.png</file>
<file>image/Dungeon/4/40.png</file>
<file>image/Dungeon/4/41.png</file>
<file>image/Dungeon/4/42.png</file>
Expand Down Expand Up @@ -94,30 +103,33 @@
<file>image/Dungeon/18/181.png</file>
<file>image/Dungeon/18/182.png</file>
<file>image/Dungeon/18/183.png</file>
<file>image/Dungeon/20/200.png</file>
<file>image/Dungeon/20/201.png</file>
<file>image/Dungeon/20/202.png</file>
<file>image/Dungeon/20/203.png</file>
<file>image/Dungeon/22/220.png</file>
<file>image/Dungeon/22/221.png</file>
<file>image/Dungeon/22/222.png</file>
<file>image/Dungeon/22/223.png</file>
<file>image/Dungeon/19/190.png</file>
<file>image/Dungeon/19/191.png</file>
<file>image/Dungeon/19/192.png</file>
<file>image/Dungeon/19/193.png</file>
<file>image/Dungeon/20/200.png</file>
<file>image/Dungeon/20/201.png</file>
<file>image/Dungeon/20/202.png</file>
<file>image/Dungeon/20/203.png</file>
<file>image/Dungeon/21/210.png</file>
<file>image/Dungeon/21/211.png</file>
<file>image/Dungeon/21/212.png</file>
<file>image/Dungeon/21/213.png</file>
<file>image/Dungeon/26.png</file>
<file>image/Dungeon/27.png</file>
<file>image/Dungeon/28.png</file>
<file>image/Dungeon/29.png</file>
<file>image/Dungeon/30.png</file>
<file>image/Dungeon/31.png</file>
<file>image/Dungeon/fog.png</file>
<file>image/Dungeon/32.png</file>
<file>image/Dungeon/dead.png</file>
<file>image/Dungeon/22/220.png</file>
<file>image/Dungeon/22/221.png</file>
<file>image/Dungeon/22/222.png</file>
<file>image/Dungeon/22/223.png</file>
</qresource>
<qresource prefix="/Cmptor">
<file>image/Cmptor/0.png</file>
<file>image/Cmptor/1.png</file>
<file>image/Cmptor/2/20.png</file>
<file>image/Cmptor/2/21.png</file>
<file>image/Cmptor/2/22.png</file>
<file>image/Cmptor/2/23.png</file>
<file>image/Cmptor/3/30.png</file>
<file>image/Cmptor/3/31.png</file>
<file>image/Cmptor/3/32.png</file>
<file>image/Cmptor/3/33.png</file>
</qresource>
</RCC>
Empty file modified 打包发布.md
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions 整体结构.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 整体结构

![pic1](./datum/1.jpg)
![](.\datum\1.jpg)

- 游戏中有迷宫模式和地牢模式两种游戏模式,主要由5个类组成

Expand All @@ -14,4 +14,4 @@

- 商店类StoreWidget主要实现地牢模式中的商店功能



18 changes: 9 additions & 9 deletions 核心实现.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- 在生成迷宫时,将可以走的路标记为1,不能走的墙标记为0。自动寻路时,从当前位置开始每次都从4个方向,按照左、下、右、上的顺序来检测前方是路还是墙(标记是1还是0),一旦找到一个方向上的路是可以走的,则将此方向上的路的坐标存储到路径栈PathStack中,并且标记已经走过的路,防止走回头路陷入死循环。如果探测后4个方向都找不到可以走的路,则将路径栈中栈顶元素出栈,回退到上一个路径点重新探测,跳过被标记为走过的路,如果4个方向依然找不到可以走的路,则重复上述步骤,将当前路径栈栈顶元素出栈,回退到上一个路径点重新探测,一直重复上述步骤,直到探测到可以走的路才将此方向上的路压入到路径栈中,并继续向前探测。生成的迷宫地图必有一条通路,所以总能找到一条通往出口的路径。

![pic2](./datum/2.jpg)
![](.\datum\2.jpg)

#### 地牢类中初始化地牢地图initialMap的实现

Expand All @@ -14,27 +14,27 @@

- 地牢中的英雄与怪物都有自身的属性,如生命值、攻击力、防御力等等,将他们都抽象为一个结构体,结构体中存储英雄与怪物的自身属性,修改起来也较为方便

![pic3](./datum/3.jpg)
![](.\datum\3.jpg)

#### 商店类中商店购买功能的实现

- 商店是通过键盘操作上移下移选项框来进行选择,再通过Enter或者Space键进行购买。在实现时重写QT键盘事件keyPressEvent来实现商店的购买功能。当检测到输入按键为W,选项框就会上移,但若选项框已停留在第一个选项上则不会上移,检测到输入按键为S时,选项框就会下移,但若选项框已停留在最后一个选项上则不会下移。当检测到输入按键为Enter或者Space时,会做出判断,如果选择的选项不是离开商店,则继续进行判断,否则关闭商店窗口。当选择的不是离开商店时,会先判断当前剩余金币是否大于等于当前购买的花费,如过小于,则不能购买,对按键操作不反应,并提示玩家,金币不足。若满足购买的花费,则执行购买操作,每次购买完成后,都会更新商店选项与购买花费,为了平衡游戏难度,“提升攻击力”与“提升防御力”选项不会更新。

![pic4](./datum/4.jpg)
![](.\datum\4.jpg)

#### 开始界面类的实现

- 开始界面提供游戏模式选择接口,玩家通过点击不同模式的选项框进入到不同的游戏模式。开始界面的背景窗口是重写绘图事件paintEvent来实现的,每当开始界面窗口更新时,都会触发绘图事件,绘制窗口背景图片。当玩家点击进入不同的游戏模式时,也会触发绘图事件,绘制不同游戏模式的窗口背景图片。

- 当玩家选择迷宫模式或者地牢模式按钮后,会出现加载进度条。加载进度条是由QT中的QprogressBar进度条类来实现的。通过Qtimer计时器类对象发出的timeout信号,来触发槽函数loading实现进度条值的变化,当进度条跑满时,使用窗口的update函数强制刷新窗口来执行绘图事件,这样就将玩家的点击与进度条的变化,窗口背景的绘制都联系起来了。

- ![pic5](./datum/5.jpg)
- ![](.\datum\5.jpg)

![pic6](./datum/6.jpg)
![](.\datum\6.jpg)

![pic7](./datum/7.jpg)
![](.\datum\7.jpg)

![pic8](./datum/8.jpg)
![](.\datum\8.jpg)



Expand All @@ -48,6 +48,6 @@

- 每种游戏模式下都有返回主界面按钮,因为在游戏设计时隐藏了主界面窗口的边框,只有通过开始界面的“离开游戏”选项才能退出游戏,在玩家点击退出游戏后,会有提示对话框,玩家必须点击“确认”按钮才会真的突出游戏,这种设计是为了防止玩家误点而关闭游戏

![pic9](./datum/9.jpg)
![](.\datum\9.jpg)

![pic10](./datum/10.jpg)
![](.\datum\10.jpg)
Empty file modified 遇到的困难.md
100644 → 100755
Empty file.
Empty file modified 项目目的.md
100644 → 100755
Empty file.

0 comments on commit 9a62b3f

Please sign in to comment.