From 7c807acb4eb4b8201d77cf02487ea4fa487c2795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Wed, 13 Apr 2022 19:42:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=B2=E5=AD=90=E6=8E=A5=E8=BF=91=E6=A4=8D?= =?UTF-8?q?=E7=89=A9=E6=97=B6=E4=BC=9A=E9=AB=98=E4=BA=AE=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/component/plant.py | 8 +++++--- source/state/level.py | 9 ++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/source/component/plant.py b/source/component/plant.py index bea2d0c..782a0d2 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -128,6 +128,8 @@ class Plant(pg.sprite.Sprite): self.animate_timer = 0 self.animate_interval = 70 # 帧播放间隔 self.hit_timer = 0 + # 被铲子指向时间 + self.highlightTime = 0 def loadFrames(self, frames, name, scale, color=c.BLACK): frame_list = tool.GFX[name] @@ -188,10 +190,10 @@ class Plant(pg.sprite.Sprite): self.animate_timer = self.current_time self.image = self.frames[self.frame_index] - if (self.current_time - self.hit_timer) >= 200: - self.image.set_alpha(255) + if ((self.current_time - self.hit_timer) < 200) or (self.current_time - self.highlightTime < 200): + self.image.set_alpha(180) else: - self.image.set_alpha(192) + self.image.set_alpha(255) def canAttack(self, zombie): if (self.state != c.SLEEP and zombie.state != c.DIE and (not zombie.lostHead) and diff --git a/source/state/level.py b/source/state/level.py index 1f16618..f379da7 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -809,10 +809,17 @@ class Level(tool.State): self.mouse_rect.centery = y surface.blit(self.mouse_image, self.mouse_rect) - def drawMouseShowPlus(self, surface): + def drawMouseShowPlus(self, surface): # 拖动铲子时的显示 x, y = pg.mouse.get_pos() self.shovel_rect.centerx = x self.shovel_rect.centery = y + map_x, map_y = self.map.getMapIndex(x, y) + for i in self.plant_groups[map_y]: + if (x >= i.rect.x and x <= i.rect.right and + y >= i.rect.y and y <= i.rect.bottom): + i.highlightTime = self.current_time + else: + i.highlight = False surface.blit(self.shovel, self.shovel_rect) def drawZombieFreezeTrap(self, i, surface):