初步实现睡莲

This commit is contained in:
星外之神 2022-04-20 16:21:51 +08:00
parent 9f3d2eae91
commit 7846003b22
43 changed files with 82 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

@ -33,7 +33,7 @@ class Map():
def isAvailable(self, map_x, map_y, plantName): def isAvailable(self, map_x, map_y, plantName):
if self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_GRASS: # 草地 if self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_GRASS: # 草地
# 首先需要判断植物是否是水生植物,水生植物不能种植在陆地上 # 首先需要判断植物是否是水生植物,水生植物不能种植在陆地上
if plantName not in {'睡莲(未实现)', '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 这里的集合也可以换成存储在某一文件中的常数的表达 if plantName not in {c.LILYPAD, '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 这里的集合也可以换成存储在某一文件中的常数的表达
if not self.map[map_y][map_x][c.MAP_PLANT]: # 没有植物肯定可以种植 if not self.map[map_y][map_x][c.MAP_PLANT]: # 没有植物肯定可以种植
return True return True
elif ((self.map[map_y][map_x][c.MAP_PLANT] | {'花盆(未实现)', '南瓜头(未实现)'} == {'花盆(未实现)', '南瓜头(未实现)'}) elif ((self.map[map_y][map_x][c.MAP_PLANT] | {'花盆(未实现)', '南瓜头(未实现)'} == {'花盆(未实现)', '南瓜头(未实现)'})
@ -47,7 +47,7 @@ class Map():
return False return False
elif self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_TILE: # 屋顶 elif self.map[map_y][map_x][c.MAP_PLOT_TYPE] == c.MAP_TILE: # 屋顶
# 首先需要判断植物是否是水生植物,水生植物不能种植在陆地上 # 首先需要判断植物是否是水生植物,水生植物不能种植在陆地上
if plantName not in {'睡莲(未实现)', '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 这里的集合也可以换成存储在某一文件中的常数的表达 if plantName not in {c.LILYPAD, '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 这里的集合也可以换成存储在某一文件中的常数的表达
if '花盆(未实现)' in self.map[map_y][map_x][c.MAP_PLANT]: if '花盆(未实现)' in self.map[map_y][map_x][c.MAP_PLANT]:
if ((self.map[map_y][map_x][c.MAP_PLANT] | {'花盆(未实现)', '南瓜头(未实现)'} == {'花盆(未实现)', '南瓜头(未实现)'}) if ((self.map[map_y][map_x][c.MAP_PLANT] | {'花盆(未实现)', '南瓜头(未实现)'} == {'花盆(未实现)', '南瓜头(未实现)'})
and (plantName not in self.map[map_y][map_x][c.MAP_PLANT])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集 and (plantName not in self.map[map_y][map_x][c.MAP_PLANT])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集
@ -61,14 +61,14 @@ class Map():
else: else:
return False return False
else: # 水里 else: # 水里
if plantName in {'睡莲(未实现)', '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 是水生植物 if plantName in {c.LILYPAD, '海蘑菇(未实现)', '缠绕水草(未实现)'}: # 是水生植物
if not self.map[map_y][map_x][c.MAP_PLANT]: # 只有无植物时才能在水里种植水生植物 if not self.map[map_y][map_x][c.MAP_PLANT]: # 只有无植物时才能在水里种植水生植物
return True return True
else: else:
return False return False
else: # 非水生植物,依赖睡莲 else: # 非水生植物,依赖睡莲
if '睡莲(未实现)' in self.map[map_y][map_x][c.MAP_PLANT]: if c.LILYPAD in self.map[map_y][map_x][c.MAP_PLANT]:
if ((self.map[map_y][map_x][c.MAP_PLANT] | {'睡莲(未实现)', '花盆(未实现)', '南瓜头(未实现)'} == {'睡莲(未实现)', '花盆(未实现)', '南瓜头(未实现)'}) if ((self.map[map_y][map_x][c.MAP_PLANT] | {c.LILYPAD, '花盆(未实现)', '南瓜头(未实现)'} == {c.LILYPAD, '花盆(未实现)', '南瓜头(未实现)'})
and (plantName not in self.map[map_y][map_x][c.MAP_PLANT])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集 and (plantName not in self.map[map_y][map_x][c.MAP_PLANT])): # 例外植物:集合中填花盆和南瓜头,只要这里没有这种植物就能种植;判断方法:并集
return True return True
else: else:

View File

@ -9,23 +9,88 @@ PANEL_X_START = 22
PANEL_Y_INTERNAL = 67 PANEL_Y_INTERNAL = 67
PANEL_X_INTERNAL = 53 PANEL_X_INTERNAL = 53
# 以后可以增加到10并且增加解锁功能 # 以后可以增加到10并且增加解锁功能
CARD_LIST_NUM = 8 CARD_MAX_NUM = 8
CARD_MAX_NUM = CARD_LIST_NUM CARD_LIST_NUM = 0
'''
plantDict = {# 字典 植物名称:(卡片名称, 阳光, 冷却时间)
c.SUNFLOWER:(c.CARD_SUNFLOWER,
50,
7500),
c.PEASHOOTER:(c.CARD_PEASHOOTER,
100,
7500),
c.SNOWPEASHOOTER:(c.CARD_SNOWPEASHOOTER,
175,
7500),
c.WALLNUT:(c.CARD_WALLNUT,
50,
30000),
c.CHERRYBOMB:(c.CARD_CHERRYBOMB,
150,
50000),
c.THREEPEASHOOTER:(c.CARD_THREEPEASHOOTER,
325,
7500),
c.REPEATERPEA:(c.CARD_REPEATERPEA,
200,
7500),
c.CHOMPER:(c.CARD_CHOMPER,
150,
7500),
c.PUFFSHROOM:(c.CARD_PUFFSHROOM,
0,
7500),
c.POTATOMINE:(c.CARD_POTATOMINE,
25,
30000),
c.SQUASH:(c.CARD_SQUASH,
50,
30000),
c.SPIKEWEED:(c.CARD_SPIKEWEED,
100,
7500),
c.JALAPENO:(c.CARD_JALAPENO,
125,
30000),
c.SCAREDYSHROOM:(c.CARD_SCAREDYSHROOM,
25,
7500),
c.SUNSHROOM:(c.CARD_SUNSHROOM,
25,
7500),
c.ICESHROOM:(c.CARD_ICESHROOM,
75,
50000),
c.HYPNOSHROOM:(c.CARD_HYPNOSHROOM,
75,
30000),
c.WALLNUTBOWLING:(c.CARD_WALLNUT,
0,
0),
c.REDWALLNUTBOWLING:(c.CARD_REDWALLNUT,
0,
0),
c.LILYPAD:(c.CARD_LILYPAD,
25,
7500)}
'''
card_name_list = [c.CARD_SUNFLOWER, c.CARD_PEASHOOTER, c.CARD_SNOWPEASHOOTER, c.CARD_WALLNUT, card_name_list = [c.CARD_SUNFLOWER, c.CARD_PEASHOOTER, c.CARD_SNOWPEASHOOTER, c.CARD_WALLNUT,
c.CARD_CHERRYBOMB, c.CARD_THREEPEASHOOTER, c.CARD_REPEATERPEA, c.CARD_CHOMPER, c.CARD_CHERRYBOMB, c.CARD_THREEPEASHOOTER, c.CARD_REPEATERPEA, c.CARD_CHOMPER,
c.CARD_PUFFSHROOM, c.CARD_POTATOMINE, c.CARD_SQUASH, c.CARD_SPIKEWEED, c.CARD_PUFFSHROOM, c.CARD_POTATOMINE, c.CARD_SQUASH, c.CARD_SPIKEWEED,
c.CARD_JALAPENO, c.CARD_SCAREDYSHROOM, c.CARD_SUNSHROOM, c.CARD_ICESHROOM, c.CARD_JALAPENO, c.CARD_SCAREDYSHROOM, c.CARD_SUNSHROOM, c.CARD_ICESHROOM,
c.CARD_HYPNOSHROOM, c.CARD_WALLNUT, c.CARD_REDWALLNUT] c.CARD_HYPNOSHROOM, c.CARD_WALLNUT, c.CARD_REDWALLNUT, c.CARD_LILYPAD]
plant_name_list = [c.SUNFLOWER, c.PEASHOOTER, c.SNOWPEASHOOTER, c.WALLNUT, plant_name_list = [c.SUNFLOWER, c.PEASHOOTER, c.SNOWPEASHOOTER, c.WALLNUT,
c.CHERRYBOMB, c.THREEPEASHOOTER, c.REPEATERPEA, c.CHOMPER, c.CHERRYBOMB, c.THREEPEASHOOTER, c.REPEATERPEA, c.CHOMPER,
c.PUFFSHROOM, c.POTATOMINE, c.SQUASH, c.SPIKEWEED, c.PUFFSHROOM, c.POTATOMINE, c.SQUASH, c.SPIKEWEED,
c.JALAPENO, c.SCAREDYSHROOM, c.SUNSHROOM, c.ICESHROOM, c.JALAPENO, c.SCAREDYSHROOM, c.SUNSHROOM, c.ICESHROOM,
c.HYPNOSHROOM, c.WALLNUTBOWLING, c.REDWALLNUTBOWLING] c.HYPNOSHROOM, c.WALLNUTBOWLING, c.REDWALLNUTBOWLING, c.LILYPAD]
plant_sun_list = [50, 100, 175, 50, 150, 325, 200, 150, 0, 25, 50, 100, 125, 25, 25, 75, 75, 0, 0] plant_sun_list = [50, 100, 175, 50, 150, 325, 200, 150, 0, 25, 50, 100, 125, 25, 25, 75, 75, 0, 0, 25]
plant_frozen_time_list = [7500, 7500, 7500, 30000, 50000, 7500, 7500, 7500, 7500, 30000, plant_frozen_time_list = [7500, 7500, 7500, 30000, 50000, 7500, 7500, 7500, 7500, 30000,
30000, 7500, 50000, 7500, 7500, 50000, 30000, 0, 0] 30000, 7500, 50000, 7500, 7500, 50000, 30000, 0, 0, 7500]
all_card_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] all_card_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19]
def getSunValueImage(sun_value): def getSunValueImage(sun_value):
# for pack, must include ttf # for pack, must include ttf
@ -55,7 +120,7 @@ def getCardPool(data):
return card_pool return card_pool
class Card(): class Card():
def __init__(self, x, y, name_index, scale=0.78): def __init__(self, x, y, name_index, scale=0.5):
self.loadFrame(card_name_list[name_index], scale) self.loadFrame(card_name_list[name_index], scale)
self.rect = self.orig_image.get_rect() self.rect = self.orig_image.get_rect()
self.rect.x = x self.rect.x = x
@ -264,7 +329,7 @@ class Panel():
x = PANEL_X_START - PANEL_X_INTERNAL x = PANEL_X_START - PANEL_X_INTERNAL
y += PANEL_Y_INTERNAL y += PANEL_Y_INTERNAL
x += PANEL_X_INTERNAL x += PANEL_X_INTERNAL
self.card_list.append(Card(x, y, index, 0.75)) self.card_list.append(Card(x, y, index, 0.5))
def checkCardClick(self, mouse_pos): def checkCardClick(self, mouse_pos):
delete_card = None delete_card = None

View File

@ -1,4 +1,4 @@
START_LEVEL_NUM = 1 START_LEVEL_NUM = 4
START_LITTLE_GAME_NUM = 1 START_LITTLE_GAME_NUM = 1
ORIGINAL_CAPTION = 'pypvz' ORIGINAL_CAPTION = 'pypvz'
@ -105,7 +105,7 @@ MAP_STATE_TILE = {MAP_PLANT:set(), MAP_SLEEP:False, MAP_PLOT_TYPE:MAP_TILE}
BACKGROUND_OFFSET_X = 220 BACKGROUND_OFFSET_X = 220
MAP_OFFSET_X = 35 MAP_OFFSET_X = 35
MAP_OFFSET_Y = 100 MAP_OFFSET_Y = 100
MAP_POOL_OFFSET_X = 40 # 暂时还不清楚数据 MAP_POOL_OFFSET_X = 45 # 暂时还不清楚数据
MAP_POOL_OFFSET_Y = 115 # 暂时还不清楚数据 MAP_POOL_OFFSET_Y = 115 # 暂时还不清楚数据
MAP_ROOF_OFFSET_X = 35 # 暂时还不清楚数据 MAP_ROOF_OFFSET_X = 35 # 暂时还不清楚数据
MAP_ROOF_OFFSET_Y = 105 # 暂时还不清楚数据 MAP_ROOF_OFFSET_Y = 105 # 暂时还不清楚数据
@ -185,6 +185,7 @@ CARD_SUNSHROOM = 'card_sunshroom'
CARD_ICESHROOM = 'card_iceshroom' CARD_ICESHROOM = 'card_iceshroom'
CARD_HYPNOSHROOM = 'card_hypnoshroom' CARD_HYPNOSHROOM = 'card_hypnoshroom'
CARD_REDWALLNUT = 'card_redwallnut' CARD_REDWALLNUT = 'card_redwallnut'
CARD_LILYPAD = 'card_lilypad'
#BULLET INFO #BULLET INFO
BULLET_PEA = 'PeaNormal' BULLET_PEA = 'PeaNormal'