add plant Jalapeno

zhangcongyu_branch
marblexu 6 years ago
parent 078c21eab8
commit cdc3fcaeed

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

@ -12,13 +12,15 @@ 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_SPIKEWEED]
c.CARD_PUFFMUSHROOM, c.CARD_POTATOMINE, c.CARD_SQUASH, c.CARD_SPIKEWEED,
c.CARD_JALAPENO]
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, 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]
c.PUFFMUSHROOM, c.POTATOMINE, c.SQUASH, c.SPIKEWEED,
c.JALAPENO]
plant_sun_list = [50, 100, 175, 50, 150, 325, 200, 150, 0, 25, 50, 100, 125]
plant_frozen_time_list = [0, 5000, 5000, 10000, 5000, 5000, 5000, 5000, 8000, 8000, 8000, 8000, 8000]
all_card_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
def getSunValueImage(sun_value):
font = pg.font.SysFont(None, 22)

@ -570,7 +570,6 @@ class Spikeweed(Plant):
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')
@ -594,4 +593,42 @@ class Spikeweed(Plant):
self.attack_timer = self.current_time
for zombie in self.zombie_group:
if self.canAttack(zombie):
zombie.setDamage(1, False)
zombie.setDamage(1, False)
class Jalapeno(Plant):
def __init__(self, x, y):
Plant.__init__(self, x, y, c.JALAPENO, c.PLANT_HEALTH, None)
self.state = c.ATTACK
self.start_explode = False
self.explode_y_range = 0
self.explode_x_range = 377
def loadImages(self, name, scale):
self.explode_frames = []
explode_name = name + 'Explode'
self.loadFrames(self.explode_frames, explode_name, 1, c.WHITE)
self.loadFrames(self.frames, name, 1, c.WHITE)
def setExplode(self):
self.changeFrames(self.explode_frames)
self.animate_timer = self.current_time
self.rect.x = c.MAP_OFFSET_X
self.start_explode = True
def animation(self):
if self.start_explode:
if(self.current_time - self.animate_timer) > 100:
self.frame_index += 1
if self.frame_index >= self.frame_num:
self.health = 0
return
self.animate_timer = self.current_time
else:
if (self.current_time - self.animate_timer) > 100:
self.frame_index += 1
if self.frame_index >= self.frame_num:
self.setExplode()
return
self.animate_timer = self.current_time
self.image = self.frames[self.frame_index]

@ -77,6 +77,7 @@ PUFFMUSHROOM = 'PuffMushroom'
POTATOMINE = 'PotatoMine'
SQUASH = 'Squash'
SPIKEWEED = 'Spikeweed'
JALAPENO = 'Jalapeno'
PLANT_HEALTH = 5
WALLNUT_HEALTH = 30
@ -103,6 +104,7 @@ CARD_PUFFMUSHROOM = 'card_puffmushroom'
CARD_POTATOMINE = 'card_potatomine'
CARD_SQUASH = 'card_squash'
CARD_SPIKEWEED = 'card_spikeweed'
CARD_JALAPENO = 'card_jalapeno'
#BULLET INFO
BULLET_PEA = 'PeaNormal'

@ -202,6 +202,8 @@ class Level(tool.State):
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))
elif self.plant_name == c.JALAPENO:
self.plant_groups[map_y].add(plant.Jalapeno(x, y))
self.menubar.decreaseSunValue(self.plant_cost)
self.menubar.setCardFrozenTime(self.plant_name)
@ -238,7 +240,8 @@ 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 or plant_name == c.SPIKEWEED:
if (plant_name == c.POTATOMINE or plant_name == c.SQUASH or
plant_name == c.SPIKEWEED or plant_name == c.JALAPENO):
color = c.WHITE
else:
color = c.BLACK
@ -298,7 +301,7 @@ class Level(tool.State):
x, y = plant.getPosition()
map_x, map_y = self.map.getMapIndex(x, y)
self.map.setMapGridType(map_x, map_y, c.MAP_EMPTY)
if (plant.name == c.CHERRYBOMB or
if (plant.name == c.CHERRYBOMB or plant.name == c.JALAPENO or
(plant.name == c.POTATOMINE and not plant.is_init)):
self.boomZombies(plant.rect.centerx, map_y, plant.explode_y_range,
plant.explode_x_range)

Loading…
Cancel
Save