为单行、三行草皮加入做好准备

This commit is contained in:
星外之神 2022-04-23 11:03:25 +08:00
parent 0bc71ab340
commit 127bbda80a
4 changed files with 15 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

View File

@ -7,6 +7,8 @@ from copy import deepcopy
class Map(): class Map():
def __init__(self, background_type): def __init__(self, background_type):
self.background_type = background_type self.background_type = background_type
# 注意从0开始编号
# 集合内容需要deepcopy
if self.background_type in {c.BACKGROUND_POOL, c.BACKGROUND_FOG}: if self.background_type in {c.BACKGROUND_POOL, c.BACKGROUND_FOG}:
self.width = c.GRID_POOL_X_LEN self.width = c.GRID_POOL_X_LEN
self.height = c.GRID_POOL_Y_LEN self.height = c.GRID_POOL_Y_LEN
@ -15,6 +17,14 @@ class Map():
self.width = c.GRID_ROOF_X_LEN self.width = c.GRID_ROOF_X_LEN
self.height = c.GRID_ROOF_Y_LEN self.height = c.GRID_ROOF_Y_LEN
self.map = [[deepcopy(c.MAP_STATE_TILE) for x in range(self.width)] for y in range(self.height)] self.map = [[deepcopy(c.MAP_STATE_TILE) for x in range(self.width)] for y in range(self.height)]
elif self.background_type == c.BACKGROUND_SINGLE:
self.width = c.GRID_X_LEN
self.height = c.GRID_Y_LEN
self.map = [[(deepcopy(c.MAP_STATE_UNAVAILABLE), deepcopy(c.MAP_STATE_EMPTY))[y == 2] for x in range(self.width)] for y in range(self.height)]
elif self.background_type == c.BACKGROUND_TRIPLE:
self.width = c.GRID_X_LEN
self.height = c.GRID_Y_LEN
self.map = [[(deepcopy(c.MAP_STATE_UNAVAILABLE), deepcopy(c.MAP_STATE_EMPTY))[y in {1, 2, 3}] for x in range(self.width)] for y in range(self.height)]
else: else:
self.width = c.GRID_X_LEN self.width = c.GRID_X_LEN
self.height = c.GRID_Y_LEN self.height = c.GRID_Y_LEN

View File

@ -445,7 +445,7 @@ class Level(tool.State):
if map_y == None: if map_y == None:
# 情况复杂:分水路和陆路,不能简单实现,需要另外加判断 # 情况复杂:分水路和陆路,不能简单实现,需要另外加判断
# 0, 1, 4, 5路为陆路2, 3路为水路 # 0, 1, 4, 5路为陆路2, 3路为水路
if self.map_data[c.BACKGROUND_TYPE] in {2, 3}: if self.map_data[c.BACKGROUND_TYPE] in {c.BACKGROUND_POOL, c.BACKGROUND_FOG}:
if name in {}: # 这里还没填,以后加了泳池模式填:水生僵尸集合 if name in {}: # 这里还没填,以后加了泳池模式填:水生僵尸集合
map_y = randint(2, 3) map_y = randint(2, 3)
elif name == '这里应该换成气球僵尸的名字(最好写调用的变量名,最好不要直接写,保持风格统一)': elif name == '这里应该换成气球僵尸的名字(最好写调用的变量名,最好不要直接写,保持风格统一)':
@ -454,6 +454,10 @@ class Level(tool.State):
map_y = randint(0, 3) map_y = randint(0, 3)
if map_y >= 2: # 后两路的map_y应当+2 if map_y >= 2: # 后两路的map_y应当+2
map_y += 2 map_y += 2
elif self.map_data[c.BACKGROUND_TYPE] == c.BACKGROUND_SINGLE:
map_y = 2
elif self.map_data[c.BACKGROUND_TYPE] == c.BACKGROUND_TRIPLE:
map_y = randint(1, 3)
else: else:
map_y = randint(0, 4) map_y = randint(0, 4)