add plant spikeweed
BIN
resources/graphics/Cards/card_spikeweed.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_0.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_1.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_10.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_11.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_12.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_13.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_14.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_15.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_16.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_17.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_18.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_2.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_3.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_4.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_5.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_6.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_7.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_8.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resources/graphics/Plants/Spikeweed/Spikeweed/Spikeweed_9.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
resources/graphics/Screen/PanelBackground.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
resources/graphics/Screen/StartButton.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
@ -12,13 +12,13 @@ CARD_LIST_NUM = 8
|
||||
|
||||
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_PUFFMUSHROOM, c.CARD_POTATOMINE, c.CARD_SQUASH]
|
||||
c.CARD_PUFFMUSHROOM, c.CARD_POTATOMINE, c.CARD_SQUASH, c.CARD_SPIKEWEED]
|
||||
plant_name_list = [c.SUNFLOWER, c.PEASHOOTER, c.SNOWPEASHOOTER, c.WALLNUT,
|
||||
c.CHERRYBOMB, c.THREEPEASHOOTER, c.REPEATERPEA, c.CHOMPER,
|
||||
c.PUFFMUSHROOM, c.POTATOMINE, c.SQUASH]
|
||||
plant_sun_list = [50, 100, 175, 50, 150, 325, 200, 150, 0, 25, 50]
|
||||
plant_frozen_time_list = [0, 5000, 5000, 10000, 5000, 5000, 5000, 5000, 8000, 8000, 8000]
|
||||
all_card_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
c.PUFFMUSHROOM, c.POTATOMINE, c.SQUASH, c.SPIKEWEED]
|
||||
plant_sun_list = [50, 100, 175, 50, 150, 325, 200, 150, 0, 25, 50, 100]
|
||||
plant_frozen_time_list = [0, 5000, 5000, 10000, 5000, 5000, 5000, 5000, 8000, 8000, 8000, 8000]
|
||||
all_card_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
||||
|
||||
def getSunValueImage(sun_value):
|
||||
font = pg.font.SysFont(None, 22)
|
||||
|
||||
@ -560,4 +560,38 @@ class Squash(Plant):
|
||||
self.animate_interval = 300
|
||||
|
||||
def getPosition(self):
|
||||
return self.orig_pos
|
||||
return self.orig_pos
|
||||
|
||||
class Spikeweed(Plant):
|
||||
def __init__(self, x, y):
|
||||
Plant.__init__(self, x, y, c.SPIKEWEED, c.PLANT_HEALTH, None)
|
||||
self.animate_interval = 200
|
||||
self.attack_timer = 0
|
||||
|
||||
def loadImages(self, name, scale):
|
||||
self.loadFrames(self.frames, name, 0.9, c.WHITE)
|
||||
self.select_image = self.frames[0]
|
||||
|
||||
def setIdle(self):
|
||||
print('spikeweed idle')
|
||||
self.animate_interval = 200
|
||||
self.state = c.IDLE
|
||||
|
||||
def canAttack(self, zombie):
|
||||
if (self.rect.x <= zombie.rect.right and
|
||||
(self.rect.right >= zombie.rect.x)):
|
||||
return True
|
||||
return False
|
||||
|
||||
def setAttack(self, zombie_group):
|
||||
print('spikeweed attack')
|
||||
self.zombie_group = zombie_group
|
||||
self.animate_interval = 50
|
||||
self.state = c.ATTACK
|
||||
|
||||
def attacking(self):
|
||||
if (self.current_time - self.attack_timer) > 2000:
|
||||
self.attack_timer = self.current_time
|
||||
for zombie in self.zombie_group:
|
||||
if self.canAttack(zombie):
|
||||
zombie.setDamage(1, False)
|
||||
@ -33,6 +33,7 @@ class Zombie(pg.sprite.Sprite):
|
||||
self.animate_interval = 150
|
||||
self.ice_slow_ratio = 1
|
||||
self.ice_slow_timer = 0
|
||||
self.hit_timer = 0
|
||||
self.speed = 1
|
||||
|
||||
def loadFrames(self, frames, name, image_x, colorkey=c.BLACK):
|
||||
@ -118,8 +119,12 @@ class Zombie(pg.sprite.Sprite):
|
||||
return
|
||||
self.frame_index = 0
|
||||
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)
|
||||
else:
|
||||
self.image.set_alpha(192)
|
||||
|
||||
def getTimeRatio(self):
|
||||
return self.ice_slow_ratio
|
||||
@ -136,6 +141,7 @@ class Zombie(pg.sprite.Sprite):
|
||||
|
||||
def setDamage(self, damage, ice):
|
||||
self.health -= damage
|
||||
self.hit_timer = self.current_time
|
||||
if ice:
|
||||
self.setIceSlow()
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
"BulletMushRoom":{"x":0, "y":1, "width":55, "height":21},
|
||||
"PotatoMine":{"x":0, "y":0, "width":75, "height":55},
|
||||
"Squash":{"x":10, "y":140, "width":80, "height":86},
|
||||
"SquashAim":{"x":10, "y":140, "width":80, "height":86}
|
||||
"SquashAim":{"x":10, "y":140, "width":80, "height":86},
|
||||
"Spikeweed":{"x":3, "y":0, "width":80, "height":35}
|
||||
}
|
||||
}
|
||||
@ -200,6 +200,8 @@ class Level(tool.State):
|
||||
self.plant_groups[map_y].add(plant.PotatoMine(x, y))
|
||||
elif self.plant_name == c.SQUASH:
|
||||
self.plant_groups[map_y].add(plant.Squash(x, y))
|
||||
elif self.plant_name == c.SPIKEWEED:
|
||||
self.plant_groups[map_y].add(plant.Spikeweed(x, y))
|
||||
|
||||
self.menubar.decreaseSunValue(self.plant_cost)
|
||||
self.menubar.setCardFrozenTime(self.plant_name)
|
||||
@ -236,7 +238,7 @@ class Level(tool.State):
|
||||
rect = frame_list[0].get_rect()
|
||||
width, height = rect.w, rect.h
|
||||
|
||||
if plant_name == c.POTATOMINE or plant_name == c.SQUASH:
|
||||
if plant_name == c.POTATOMINE or plant_name == c.SQUASH or plant_name == c.SPIKEWEED:
|
||||
color = c.WHITE
|
||||
else:
|
||||
color = c.BLACK
|
||||
@ -269,7 +271,7 @@ class Level(tool.State):
|
||||
for i in range(self.map_y_len):
|
||||
for zombie in self.zombie_groups[i]:
|
||||
plant = pg.sprite.spritecollideany(zombie, self.plant_groups[i], collided_func)
|
||||
if plant and zombie.state == c.WALK:
|
||||
if plant and plant.name != c.SPIKEWEED and zombie.state == c.WALK:
|
||||
zombie.setAttack(plant)
|
||||
plant.setAttacked()
|
||||
|
||||
@ -336,6 +338,16 @@ class Level(tool.State):
|
||||
if plant.canAttack(zombie):
|
||||
plant.setAttack(zombie, self.zombie_groups[i])
|
||||
break
|
||||
elif plant.name == c.SPIKEWEED:
|
||||
can_attack = False
|
||||
for zombie in self.zombie_groups[i]:
|
||||
if plant.canAttack(zombie):
|
||||
can_attack = True
|
||||
break
|
||||
if plant.state == c.IDLE and can_attack:
|
||||
plant.setAttack(self.zombie_groups[i])
|
||||
elif plant.state == c.ATTACK and not can_attack:
|
||||
plant.setIdle()
|
||||
else:
|
||||
if (plant.state == c.IDLE and zombie_len > 0):
|
||||
for zombie in self.zombie_groups[i]:
|
||||
|
||||