Skip to content

Commit f7135d3

Browse files
committed
Small update and pickle transfer.
1 parent 941b0f2 commit f7135d3

12 files changed

+100
-49
lines changed

README.md

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,63 @@
11
# Ethians-Alpha-1.1
2-
## My own Rougelike game during the first year of university. This project is currently suspended.
3-
4-
### A Rougelike game, in the hope of implement some of my own ideas. About the origin version of this project, search `Dweller`.
5-
#### `asset`文件夹中部分图片来源与`Dweller`这个游戏,包括所有monster, 一半的items, 其余都是个人创作
6-
> * 2019年一月开始断断续续写这个项目,知道2019年8月29日写完
7-
> * 在上完数据结构与算法后,对这个项目进行了一些优化,但是很有限,这个项目的代码结构太乱,类间的调用关系不清晰,可维护性很差,所以我称之为“练手项目”
8-
> * 对于这个游戏,以后有时间可能进行重构(甚至重写),里面太多的实现在我现在看来都是垃圾。
9-
> * 值得一提的是,我现在大二,代码技术也很垃圾
10-
> * 个人不想再使用Pygame做这个项目,Pygame没有很好的交互系统,只能自己写交互,有点难受
2+
3+
---
4+
5+
## I. Intros
6+
7+
My own Rougelike game during the first year of university. This project is currently suspended until 2021.11.27, the latest minor revisions and organization are added.
8+
9+
A Rougelike game, in the hope of implement some of my own ideas. About the origin version of this project, search `Dweller`.
10+
11+
`asset`文件夹中部分图片来源与`Dweller`这个游戏,包括所有monster, 部分items, 其余都是个人使用PS进行的创作:
12+
13+
* 2019年一月开始断断续续写这个项目,知道2019年8月29日写完
14+
* 在上完数据结构与算法后,对这个项目进行了一些优化,但是很有限,这个项目的代码结构太乱,类间的调用关系不清晰,可维护性很差,所以我称之为“练手项目”
15+
* 对于这个游戏,以后有时间可能进行重构(甚至重写),里面太多的实现在我现在看来都是垃圾。
16+
* 个人不想再使用Pygame做这个项目,Pygame没有很好的交互系统,只能自己写交互,有点难受。如果需要重构,预计使用C#实现,可以省去GUI、动画、交互以及并行程序的开发
17+
18+
---
19+
20+
## II. Attributes
21+
22+
### 2.1 随机生成的地图
23+
24+
- 地牢随机生成,并且附带地图编辑器,可以自定义地图。
25+
- 陷阱,宝箱,怪物,地形丰富
26+
- FOV shadow casting 迷雾算法,小地图显示
27+
28+
![](README/Screenshot 2021-11-28 033344.png)
29+
30+
### 2.2 装备\背包系统
31+
32+
- 装备等级与词缀加成
33+
- 附魔升级以及随机名字 + 随机属性
34+
- 装备掉落系统
35+
- 人物属性、抗性系统,游戏信息记录
36+
- 三个职业:狂战士,游侠,巫师
37+
- 人物等级系统,商店交易系统,可与NPC进行对话
38+
39+
![](README/Screenshot 2021-11-28 033622.png)
40+
41+
![](README/Screenshot 2021-11-28 033602.png)
42+
43+
### 2.3 主菜单与彩蛋
44+
45+
- 游戏编写者的彩蛋世界,内有编写者的家人
46+
- 英灵殿:记录死亡信息,记录通关信息
47+
- 支持游戏保存
48+
- 支持进行键盘设置
49+
50+
![](README/Screenshot 2021-11-28 034341.png)
51+
52+
![](README/Screenshot 2021-11-28 033804.png)
53+
54+
---
55+
56+
## III. Play
57+
58+
​ 应该只依赖于Pygame库(Pygame 1.9.6),Windows / Ubuntu均可
59+
60+
```
61+
python ./main.py
62+
```
63+
561 KB
Loading
2.35 MB
Loading
1.89 MB
Loading
798 KB
Loading
279 KB
Loading

data/playerData.pkl

9.96 KB
Binary file not shown.

equipment/equip.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
sys.path.append("..")
77
from src.ezplot import MySprite
88
from equipment.enchant import *
9+
from collections import deque
910

1011
class FloorEquipManage:
1112
def __init__(self, surface):
@@ -103,8 +104,8 @@ def center(self, cx, cy): #绘制装备
103104
for x in range(4, 60):
104105
stuff=self.getChar(x, y)
105106
if stuff>=0:
106-
posx=(16-cx)*32+80+x*32
107-
posy=(9-cy)*32+10+y*32
107+
posx=((16-cx) << 5) + 80 + (x << 5)
108+
posy=((9-cy) << 5)+ 10 + (y << 5)
108109
image=self.All.getImage(stuff)
109110
self.screen.blit(image, (posx, posy))
110111

@@ -115,8 +116,8 @@ def rangeCenter(self, cx, cy, n): #只在一定范围内进行的center
115116
for y in range(y_min, y_max):
116117
stuff=self.getChar(x, y)
117118
if stuff>=0 and self.pl.ms.getChar(x, y)==1: #在光照范围内
118-
posx=(16-cx)*32+80+x*32
119-
posy=(9-cy)*32+10+y*32
119+
posx=((16-cx) << 5) + 80 + (x << 5)
120+
posy=((9-cy) << 5)+ 10 + (y << 5)
120121
image = self.All.getImage(stuff)
121122
self.screen.blit(image, (posx, posy))
122123

@@ -159,27 +160,33 @@ def canPlace(self, x, y):
159160
#由于在本游戏中,掉落或者开启宝箱的物品全部出现在地面上,我们将概率问题委托给fem处理
160161
def mobItemDrop(self, tuple1, trs, lvl): #给mobs实例使用的
161162
eq=self.mobDropModule(trs, lvl)
162-
if self.canPlace(*tuple1): #可以原地掉落时,掉落在原地
163-
self.dropOne(eq, *tuple1)
164-
else: #原地无法掉落时,在附近八格寻找
165-
x, y=tuple1
166-
for i in range(x-1, x+2):
167-
for j in range(y-1, y+2):
168-
if self.canPlace(i, j):
169-
self.dropOne(eq, i, j)
170-
return
163+
x, y = tuple1
164+
drop_deque = deque()
165+
drop_deque.append((x, y))
166+
while len(drop_deque) > 0: # BFS
167+
i, j = drop_deque.popleft()
168+
if self.canPlace(i, j):
169+
self.dropOne(eq, i, j)
170+
return
171+
for m in range(i-1, i+2):
172+
for n in range(j-1, j+2):
173+
if m == i and j == n: continue
174+
drop_deque.append((m, n))
171175

172176
def boxItemDrop(self, tuple1, lvl):
173177
eq=self.boxDropModule(lvl)
174-
if self.canPlace(*tuple1): #可以原地掉落时,掉落在原地
175-
self.dropOne(eq, *tuple1)
176-
else: #原地无法掉落时,在附近八格寻找
177-
x, y=tuple1
178-
for i in range(x-1, x+2):
179-
for j in range(y-1, y+2):
180-
if self.canPlace(i, j):
181-
self.dropOne(eq, i, j)
182-
return
178+
x, y = tuple1
179+
drop_deque = deque()
180+
drop_deque.append((x, y))
181+
while len(drop_deque) > 0:
182+
i, j = drop_deque.popleft()
183+
if self.canPlace(i, j):
184+
self.dropOne(eq, i, j)
185+
return
186+
for m in range(i-1, i+2):
187+
for n in range(j-1, j+2):
188+
if m == i and j == n: continue
189+
drop_deque.append((m, n))
183190

184191
def mobDropModule(self, trs, lvl):
185192
if trs==-1: #本怪物没有特征掉落物(比如史莱姆的特征掉落物是钱)

src/Pathfinder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#-*-coding:utf-8-*-
33
#Pathfinder
44
import sys
5-
import numpy as np
5+
from numpy import sqrt
66

77
class Point:
88
def __init__(self, x, y):
@@ -19,7 +19,7 @@ def __init__(self, func_lst=None):
1919
self.__found=False
2020
self.open_set=[]
2121
self.close_set=[]
22-
self.d2=np.sqrt(2)
22+
self.d2 = sqrt(2)
2323
self.start=Point(0, 0)
2424
self.goal=Point(0, 0)
2525
self.func_lst=[func_lst]

src/cursors.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,7 @@ def interact(self, remote=False): #这个是交互,remote参数默认
103103
#应该实现:近距离的开关宝箱,清除陷阱,开关门。
104104
#func_lst的参数是[dg.sur, npc]
105105
if not remote:
106-
print("Tryed")
107106
if [self.xat, self.yat] in self.pos_lst and not self.func_lst[0].getChar(self.xat, self.yat):
108-
"""for i in range(1, self.len_lst):
109-
where=self.func_lst[i].getChar(self.xat, self.yat)
110-
if where in self.func_lst[i].inter_dict:
111-
if i-1:
112-
self.func_lst[i].inter_dict[ where ]()
113-
else:
114-
self.func_lst[i].interDict(self.xat, self.yat, where) #索引和传参都是where
115-
else: return False"""
116107
where = self.func_lst[1].getChar(self.xat, self.yat)
117108
if where in self.func_lst[1].inter_dict:
118109
self.func_lst[1].interDict(self.xat, self.yat, where) # 索引和传参都是where
@@ -152,8 +143,8 @@ def center(self, surface, target): #基准点是(16,9),表示把(x
152143
for x in range(64):
153144
value=target.getChar(x, y)
154145
if value>=0:
155-
target.image.X=(16-self.posx)*32+80+x*32
156-
target.image.Y=(9-self.posy)*32+10+y*32
146+
target.image.X=((16 - self.posx) << 5) + 80 + (x << 5)
147+
target.image.Y=((9 - self.posy) << 5) + 10 + (y << 5)
157148
target.image.frame=value
158149
target.image.last_frame=value
159150
target.image.update(0)

0 commit comments

Comments
 (0)