add plant sunshroom

zhangcongyu_branch
marblexu 6 years ago
parent c9038b31fb
commit 1281c0363e

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

@ -13,15 +13,15 @@ CARD_LIST_NUM = 8
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_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, c.CARD_SCAREDYSHROOM] c.CARD_JALAPENO, c.CARD_SCAREDYSHROOM, c.CARD_SUNSHROOM]
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.PUFFMUSHROOM, c.POTATOMINE, c.SQUASH, c.SPIKEWEED, c.PUFFMUSHROOM, c.POTATOMINE, c.SQUASH, c.SPIKEWEED,
c.JALAPENO, c.SCAREDYSHROOM] c.JALAPENO, c.SCAREDYSHROOM, c.SUNSHROOM]
plant_sun_list = [50, 100, 175, 50, 150, 325, 200, 150, 0, 25, 50, 100, 125, 25] plant_sun_list = [50, 100, 175, 50, 150, 325, 200, 150, 0, 25, 50, 100, 125, 25, 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] 30000, 7500, 50000, 7500, 7500]
all_card_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] all_card_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
def getSunValueImage(sun_value): def getSunValueImage(sun_value):
font = pg.font.SysFont(None, 22) font = pg.font.SysFont(None, 22)
@ -106,7 +106,7 @@ class Card():
return image return image
def update(self, sun_value, current_time): def update(self, sun_value, current_time):
if (current_time - self.refresh_timer) >= 500: if (current_time - self.refresh_timer) >= 250:
self.image = self.createShowImage(sun_value, current_time) self.image = self.createShowImage(sun_value, current_time)
self.refresh_timer = current_time self.refresh_timer = current_time

@ -210,8 +210,14 @@ class Plant(pg.sprite.Sprite):
return self.rect.centerx, self.rect.bottom return self.rect.centerx, self.rect.bottom
class Sun(Plant): class Sun(Plant):
def __init__(self, x, y, dest_x, dest_y): def __init__(self, x, y, dest_x, dest_y, is_big=True):
Plant.__init__(self, x, y, c.SUN, 0, None, 0.9) if is_big:
scale = 0.9
self.sun_value = c.SUN_VALUE
else:
scale = 0.6
self.sun_value = 12
Plant.__init__(self, x, y, c.SUN, 0, None, scale)
self.move_speed = 1 self.move_speed = 1
self.dest_x = dest_x self.dest_x = dest_x
self.dest_y = dest_y self.dest_y = dest_y
@ -672,4 +678,43 @@ class ScaredyShroom(Plant):
if (self.current_time - self.shoot_timer) > 2000: if (self.current_time - self.shoot_timer) > 2000:
self.bullet_group.add(Bullet(self.rect.right, self.rect.y + 40, self.rect.y + 40, self.bullet_group.add(Bullet(self.rect.right, self.rect.y + 40, self.rect.y + 40,
c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, True)) c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, True))
self.shoot_timer = self.current_time self.shoot_timer = self.current_time
class SunShroom(Plant):
def __init__(self, x, y, sun_group):
Plant.__init__(self, x, y, c.SUNSHROOM, c.PLANT_HEALTH, None)
self.animate_interval = 200
self.sun_timer = 0
self.sun_group = sun_group
self.is_big = False
self.change_timer = 0
def loadImages(self, name, scale):
self.idle_frames = []
self.big_frames = []
idle_name = name
big_name = name + 'Big'
frame_list = [self.idle_frames, self.big_frames]
name_list = [idle_name, big_name]
for i, name in enumerate(name_list):
self.loadFrames(frame_list[i], name, 1, c.WHITE)
self.frames = self.idle_frames
def idling(self):
if not self.is_big:
if self.change_timer == 0:
self.change_timer = self.current_time
elif (self.current_time - self.change_timer) > 25000:
self.changeFrames(self.big_frames)
self.is_big = True
if self.sun_timer == 0:
self.sun_timer = self.current_time - (c.FLOWER_SUN_INTERVAL - 6000)
elif (self.current_time - self.sun_timer) > c.FLOWER_SUN_INTERVAL:
self.sun_group.add(Sun(self.rect.centerx, self.rect.bottom, self.rect.right,
self.rect.bottom + self.rect.h // 2, self.is_big))
self.sun_timer = self.current_time

@ -79,6 +79,7 @@ SQUASH = 'Squash'
SPIKEWEED = 'Spikeweed' SPIKEWEED = 'Spikeweed'
JALAPENO = 'Jalapeno' JALAPENO = 'Jalapeno'
SCAREDYSHROOM = 'ScaredyShroom' SCAREDYSHROOM = 'ScaredyShroom'
SUNSHROOM = 'SunShroom'
PLANT_HEALTH = 5 PLANT_HEALTH = 5
WALLNUT_HEALTH = 30 WALLNUT_HEALTH = 30
@ -107,6 +108,7 @@ CARD_SQUASH = 'card_squash'
CARD_SPIKEWEED = 'card_spikeweed' CARD_SPIKEWEED = 'card_spikeweed'
CARD_JALAPENO = 'card_jalapeno' CARD_JALAPENO = 'card_jalapeno'
CARD_SCAREDYSHROOM = 'card_scaredyshroom' CARD_SCAREDYSHROOM = 'card_scaredyshroom'
CARD_SUNSHROOM = 'card_sunshroom'
#BULLET INFO #BULLET INFO
BULLET_PEA = 'PeaNormal' BULLET_PEA = 'PeaNormal'

@ -139,7 +139,7 @@ class Level(tool.State):
if not self.drag_plant and mouse_pos and mouse_click[0]: if not self.drag_plant and mouse_pos and mouse_click[0]:
for sun in self.sun_group: for sun in self.sun_group:
if sun.checkCollision(mouse_pos[0], mouse_pos[1]): if sun.checkCollision(mouse_pos[0], mouse_pos[1]):
self.menubar.increaseSunValue(c.SUN_VALUE) self.menubar.increaseSunValue(sun.sun_value)
for car in self.cars: for car in self.cars:
car.update(self.game_info) car.update(self.game_info)
@ -206,6 +206,8 @@ class Level(tool.State):
self.plant_groups[map_y].add(plant.Jalapeno(x, y)) self.plant_groups[map_y].add(plant.Jalapeno(x, y))
elif self.plant_name == c.SCAREDYSHROOM: elif self.plant_name == c.SCAREDYSHROOM:
self.plant_groups[map_y].add(plant.ScaredyShroom(x, y, self.bullet_groups[map_y])) self.plant_groups[map_y].add(plant.ScaredyShroom(x, y, self.bullet_groups[map_y]))
elif self.plant_name == c.SUNSHROOM:
self.plant_groups[map_y].add(plant.SunShroom(x, y, self.sun_group))
self.menubar.decreaseSunValue(self.plant_cost) self.menubar.decreaseSunValue(self.plant_cost)
self.menubar.setCardFrozenTime(self.plant_name) self.menubar.setCardFrozenTime(self.plant_name)
@ -244,7 +246,7 @@ class Level(tool.State):
if (plant_name == c.POTATOMINE or plant_name == c.SQUASH or if (plant_name == c.POTATOMINE or plant_name == c.SQUASH or
plant_name == c.SPIKEWEED or plant_name == c.JALAPENO or plant_name == c.SPIKEWEED or plant_name == c.JALAPENO or
plant_name == c.SCAREDYSHROOM): plant_name == c.SCAREDYSHROOM or plant_name == c.SUNSHROOM):
color = c.WHITE color = c.WHITE
else: else:
color = c.BLACK color = c.BLACK

Loading…
Cancel
Save