diff --git a/source/component/plant.py b/source/component/plant.py index 828d161..32b244b 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -48,7 +48,7 @@ class Bullet(pg.sprite.Sprite): self.rect.x = x self.rect.y = start_y self.dest_y = dest_y - self.y_vel = 4 if (dest_y > start_y) else -4 + self.y_vel = 15 if (dest_y > start_y) else -15 self.x_vel = 10 self.damage = damage self.effect = effect @@ -107,7 +107,7 @@ class Bullet(pg.sprite.Sprite): def draw(self, surface): surface.blit(self.image, self.rect) -# 暂时是杨桃的子弹,以后可以扩展到非定行飞行的子弹 +# 杨桃的子弹,看作豌豆、孢子类子弹的特殊子类 class StarBullet(Bullet): def __init__(self, x, y, name): self.name = name @@ -324,11 +324,12 @@ class RepeaterPea(Plant): class ThreePeaShooter(Plant): - def __init__(self, x, y, bullet_groups, map_y): + def __init__(self, x, y, bullet_groups, map_y, background_type): Plant.__init__(self, x, y, c.THREEPEASHOOTER, c.PLANT_HEALTH, None) self.shoot_timer = 0 self.map_y = map_y self.bullet_groups = bullet_groups + self.background_type = background_type def attacking(self): if (self.current_time - self.shoot_timer) > 1400: @@ -337,7 +338,10 @@ class ThreePeaShooter(Plant): tmp_y = self.map_y + (i - 1) if tmp_y < 0 or tmp_y >= c.GRID_Y_LEN: continue - dest_y = self.rect.y + (i - 1) * c.GRID_Y_SIZE + offset_y + if self.background_type in {c.BACKGROUND_POOL, c.BACKGROUND_FOG, c.BACKGROUND_ROOF, c.BACKGROUND_ROOFNIGHT}: + dest_y = self.rect.y + (i - 1) * c.GRID_POOL_Y_SIZE + offset_y + else: + dest_y = self.rect.y + (i - 1) * c.GRID_Y_SIZE + offset_y self.bullet_groups[tmp_y].add(Bullet(self.rect.right - 15, self.rect.y, dest_y, c.BULLET_PEA, c.BULLET_DAMAGE_NORMAL, effect=False)) self.shoot_timer = self.current_time diff --git a/source/constants.py b/source/constants.py index c0da0a7..064e3e1 100755 --- a/source/constants.py +++ b/source/constants.py @@ -46,8 +46,6 @@ PURPLE = (255, 0, 255) GOLD = (255, 215, 0) GREEN = ( 0, 255, 0) -# SIZE_MULTIPLIER = 1.3 # 没有用 - # 退出游戏按钮 EXIT = 'exit' # 当想要一个特殊值时用 @@ -76,6 +74,7 @@ GAME_LOSE = 'game los' GAME_VICTORY = 'game victory' LEVEL = 'level' +# 界面图片文件名 MAIN_MENU_IMAGE = 'MainMenu' OPTION_ADVENTURE = 'Adventure' GAME_LOOSE_IMAGE = 'GameLoose' @@ -102,10 +101,15 @@ BACKGROUND_TRIPLE = 8 MAP_PLANT = 'plantnames' MAP_SLEEP = 'sleep' # 有没有休眠的蘑菇,作是否能种植咖啡豆的判断 MAP_PLOT_TYPE = 'plotType' +# 地图单元格区域类型 MAP_GRASS = 'grass' MAP_WATER = 'water' MAP_TILE = 'tile' # 指屋顶上的瓦片 -MAP_UNAVAILABLE = 'unavailable' # 指完全不能种植物的地方,包括无草皮的荒地、毁灭菇坑、冰车留下的冰 +MAP_UNAVAILABLE = 'unavailable' # 指完全不能种植物的地方,包括无草皮的荒地和坚果保龄球等红线右侧 +# 特殊的:冰车冰路(自动消除、辣椒消除)、毁灭菇坑(自动消除),由于这些只能在关卡中产生而不能初始化产生,所以只有区域类型没有初始状态 +MAP_FROZEN = 'frozen' +MAP_HOLE = 'hole' +# 地图单元格状态 MAP_STATE_EMPTY = {MAP_PLANT:set(), MAP_SLEEP:False, MAP_PLOT_TYPE:MAP_GRASS} # 由于同一格显然不可能种两个相同的植物,所以用集合 MAP_STATE_WATER = {MAP_PLANT:set(), MAP_SLEEP:False, MAP_PLOT_TYPE:MAP_WATER} MAP_STATE_TILE = {MAP_PLANT:set(), MAP_SLEEP:False, MAP_PLOT_TYPE:MAP_TILE} @@ -181,8 +185,9 @@ TORCHWOOD = 'TorchWood' # 植物生命值 PLANT_HEALTH = 300 WALLNUT_HEALTH = 4000 -WALLNUT_CRACKED1_HEALTH = 4000//3 * 2 -WALLNUT_CRACKED2_HEALTH = 4000//3 +WALLNUT_CRACKED1_HEALTH = WALLNUT_HEALTH//3 * 2 +WALLNUT_CRACKED2_HEALTH = WALLNUT_HEALTH//3 +# 坚果保龄球攻击伤害 WALLNUT_BOWLING_DAMAGE = 550 # 阳光生成属性 diff --git a/source/state/level.py b/source/state/level.py index c96178c..1a0b87b 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -504,7 +504,7 @@ class Level(tool.State): elif self.plant_name == c.CHERRYBOMB: new_plant = plant.CherryBomb(x, y) elif self.plant_name == c.THREEPEASHOOTER: - new_plant = plant.ThreePeaShooter(x, y, self.bullet_groups, map_y) + new_plant = plant.ThreePeaShooter(x, y, self.bullet_groups, map_y, self.map.background_type) elif self.plant_name == c.REPEATERPEA: new_plant = plant.RepeaterPea(x, y, self.bullet_groups[map_y]) elif self.plant_name == c.CHOMPER: