diff --git a/resources/graphics/Cards/card_iceshroom.png b/resources/graphics/Cards/card_iceshroom.png new file mode 100644 index 0000000..6ab9c79 Binary files /dev/null and b/resources/graphics/Cards/card_iceshroom.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_0.png b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_0.png new file mode 100644 index 0000000..1722a55 Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_0.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_1.png b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_1.png new file mode 100644 index 0000000..2fc5009 Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_1.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_10.png b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_10.png new file mode 100644 index 0000000..5e9d71c Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_10.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_2.png b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_2.png new file mode 100644 index 0000000..98e4305 Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_2.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_3.png b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_3.png new file mode 100644 index 0000000..37122a8 Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_3.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_4.png b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_4.png new file mode 100644 index 0000000..42cb3e3 Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_4.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_5.png b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_5.png new file mode 100644 index 0000000..2155059 Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_5.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_6.png b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_6.png new file mode 100644 index 0000000..4369cac Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_6.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_7.png b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_7.png new file mode 100644 index 0000000..b1d4508 Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_7.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_8.png b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_8.png new file mode 100644 index 0000000..b1d4508 Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_8.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_9.png b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_9.png new file mode 100644 index 0000000..5e9d71c Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroom/IceShroom_9.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroomSnow/IceShroomSnow_0.png b/resources/graphics/Plants/IceShroom/IceShroomSnow/IceShroomSnow_0.png new file mode 100644 index 0000000..1706ff1 Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroomSnow/IceShroomSnow_0.png differ diff --git a/resources/graphics/Plants/IceShroom/IceShroomTrap/IceShroomTrap_0.png b/resources/graphics/Plants/IceShroom/IceShroomTrap/IceShroomTrap_0.png new file mode 100644 index 0000000..c7ccfa7 Binary files /dev/null and b/resources/graphics/Plants/IceShroom/IceShroomTrap/IceShroomTrap_0.png differ diff --git a/source/component/menubar.py b/source/component/menubar.py index 432ffa9..2110d0a 100644 --- a/source/component/menubar.py +++ b/source/component/menubar.py @@ -13,15 +13,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_JALAPENO, c.CARD_SCAREDYSHROOM, c.CARD_SUNSHROOM] + c.CARD_JALAPENO, c.CARD_SCAREDYSHROOM, c.CARD_SUNSHROOM, c.CARD_ICESHROOM] 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, - c.JALAPENO, c.SCAREDYSHROOM, c.SUNSHROOM] -plant_sun_list = [50, 100, 175, 50, 150, 325, 200, 150, 0, 25, 50, 100, 125, 25, 25] + c.JALAPENO, c.SCAREDYSHROOM, c.SUNSHROOM, c.ICESHROOM] +plant_sun_list = [50, 100, 175, 50, 150, 325, 200, 150, 0, 25, 50, 100, 125, 25, 25, 75] plant_frozen_time_list = [7500, 7500, 7500, 30000, 50000, 7500, 7500, 7500, 7500, 30000, - 30000, 7500, 50000, 7500, 7500] -all_card_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] + 30000, 7500, 50000, 7500, 7500, 50000] +all_card_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] def getSunValueImage(sun_value): font = pg.font.SysFont(None, 22) diff --git a/source/component/plant.py b/source/component/plant.py index 07ec95e..bc503fe 100644 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -717,4 +717,56 @@ class SunShroom(Plant): 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 \ No newline at end of file + self.sun_timer = self.current_time + +class IceShroom(Plant): + def __init__(self, x, y): + Plant.__init__(self, x, y, c.ICESHROOM, c.PLANT_HEALTH, None) + self.orig_pos = (x, y) + self.state = c.ATTACK + self.start_freeze = False + + def loadImages(self, name, scale): + self.idle_frames = [] + self.snow_frames = [] + self.trap_frames = [] + + idle_name = name + snow_name = name + 'Snow' + trap_name = name + 'Trap' + + frame_list = [self.idle_frames, self.snow_frames, self.trap_frames] + name_list = [idle_name, snow_name, trap_name] + scale_list = [1, 1.5, 1] + + for i, name in enumerate(name_list): + self.loadFrames(frame_list[i], name, scale_list[i], c.WHITE) + + self.frames = self.idle_frames + + def setFreeze(self): + self.changeFrames(self.snow_frames) + self.animate_timer = self.current_time + self.rect.x = c.MAP_OFFSET_X + self.rect.y = c.MAP_OFFSET_Y + self.start_freeze = True + + def animation(self): + if self.start_freeze: + if(self.current_time - self.animate_timer) > 500: + 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.setFreeze() + return + self.animate_timer = self.current_time + self.image = self.frames[self.frame_index] + + def getPosition(self): + return self.orig_pos \ No newline at end of file diff --git a/source/component/zombie.py b/source/component/zombie.py index eb21a00..bb2b720 100644 --- a/source/component/zombie.py +++ b/source/component/zombie.py @@ -35,6 +35,7 @@ class Zombie(pg.sprite.Sprite): self.ice_slow_timer = 0 self.hit_timer = 0 self.speed = 1 + self.freeze_timer = 0 def loadFrames(self, frames, name, image_x, colorkey=c.BLACK): frame_list = tool.GFX[name] @@ -58,6 +59,8 @@ class Zombie(pg.sprite.Sprite): self.attacking() elif self.state == c.DIE: self.dying() + elif self.state == c.FREEZE: + self.freezing() def walking(self): if self.health <= 0: @@ -91,7 +94,19 @@ class Zombie(pg.sprite.Sprite): def dying(self): pass - + + def freezing(self): + if self.health <= 0: + self.setDie() + elif self.health <= c.LOSTHEAD_HEALTH and not self.losHead: + if self.old_state == c.WALK: + self.changeFrames(self.losthead_walk_frames) + else: + self.changeFrames(self.losthead_attack_frames) + self.setLostHead() + if (self.current_time - self.freeze_timer) > c.FREEZE_TIME: + self.setWalk() + def setLostHead(self): self.losHead = True if self.head_group is not None: @@ -111,6 +126,10 @@ class Zombie(pg.sprite.Sprite): self.rect.centerx = centerx def animation(self): + if self.state == c.FREEZE: + self.image.set_alpha(192) + return + if (self.current_time - self.animate_timer) > (self.animate_interval * self.getTimeRatio()): self.frame_index += 1 if self.frame_index >= self.frame_num: @@ -178,6 +197,19 @@ class Zombie(pg.sprite.Sprite): self.animate_interval = 200 self.changeFrames(self.boomdie_frames) + def setFreeze(self, ice_trap_image): + self.old_state = self.state + self.state = c.FREEZE + self.freeze_timer = self.current_time + self.ice_trap_image = ice_trap_image + self.ice_trap_rect = ice_trap_image.get_rect() + self.ice_trap_rect.centerx = self.rect.centerx + self.ice_trap_rect.bottom = self.rect.bottom + + def drawFreezeTrap(self, surface): + if self.state == c.FREEZE: + surface.blit(self.ice_trap_image, self.ice_trap_rect) + class ZombieHead(Zombie): def __init__(self, x, y): Zombie.__init__(self, x, y, c.ZOMBIE_HEAD, 0) diff --git a/source/constants.py b/source/constants.py index 2f4f27d..1483082 100644 --- a/source/constants.py +++ b/source/constants.py @@ -80,6 +80,7 @@ SPIKEWEED = 'Spikeweed' JALAPENO = 'Jalapeno' SCAREDYSHROOM = 'ScaredyShroom' SUNSHROOM = 'SunShroom' +ICESHROOM = 'IceShroom' PLANT_HEALTH = 5 WALLNUT_HEALTH = 30 @@ -93,6 +94,9 @@ SUN_VALUE = 25 ICE_SLOW_TIME = 2000 +FREEZE_TIME = 7500 +ICETRAP = 'IceTrap' + #PLANT CARD INFO CARD_SUNFLOWER = 'card_sunflower' CARD_PEASHOOTER = 'card_peashooter' @@ -109,6 +113,8 @@ CARD_SPIKEWEED = 'card_spikeweed' CARD_JALAPENO = 'card_jalapeno' CARD_SCAREDYSHROOM = 'card_scaredyshroom' CARD_SUNSHROOM = 'card_sunshroom' +CARD_ICESHROOM = 'card_iceshroom' + #BULLET INFO BULLET_PEA = 'PeaNormal' @@ -148,7 +154,12 @@ DIGEST = 'digest' WALK = 'walk' DIE = 'die' CRY = 'cry' +FREEZE = 'freeze' #LEVEL STATE CHOOSE = 'choose' PLAY = 'play' + +#BACKGROUND +BACKGROUND_DAY = 0 +BACKGROUND_NIGHT = 1 \ No newline at end of file diff --git a/source/state/level.py b/source/state/level.py index 868f374..3c6e7fd 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -212,6 +212,8 @@ class Level(tool.State): 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)) + elif self.plant_name == c.ICESHROOM: + self.plant_groups[map_y].add(plant.IceShroom(x, y)) self.menubar.decreaseSunValue(self.plant_cost) self.menubar.setCardFrozenTime(self.plant_name) @@ -250,7 +252,8 @@ class Level(tool.State): if (plant_name == c.POTATOMINE or plant_name == c.SQUASH or plant_name == c.SPIKEWEED or plant_name == c.JALAPENO or - plant_name == c.SCAREDYSHROOM or plant_name == c.SUNSHROOM): + plant_name == c.SCAREDYSHROOM or plant_name == c.SUNSHROOM or + plant_name == c.ICESHROOM): color = c.WHITE else: color = c.BLACK @@ -305,6 +308,12 @@ class Level(tool.State): if abs(zombie.rect.x - x) <= x_range: zombie.setBoomDie() + def freezeZombies(self, plant): + for i in range(self.map_y_len): + for zombie in self.zombie_groups[i]: + if zombie.rect.centerx < c.SCREEN_WIDTH: + zombie.setFreeze(plant.trap_frames[0]) + def killPlant(self, plant): x, y = plant.getPosition() map_x, map_y = self.map.getMapIndex(x, y) @@ -313,6 +322,9 @@ class Level(tool.State): (plant.name == c.POTATOMINE and not plant.is_init)): self.boomZombies(plant.rect.centerx, map_y, plant.explode_y_range, plant.explode_x_range) + elif plant.name == c.ICESHROOM: + self.freezeZombies(plant) + plant.kill() def checkPlant(self, plant, i): @@ -427,7 +439,11 @@ class Level(tool.State): self.mouse_rect.centerx = x self.mouse_rect.centery = y surface.blit(self.mouse_image, self.mouse_rect) - + + def drawZombieFreezeTrap(self, i, surface): + for zombie in self.zombie_groups[i]: + zombie.drawFreezeTrap(surface) + def draw(self, surface): self.level.blit(self.background, self.viewport, self.viewport) surface.blit(self.level, (0,0), self.viewport) @@ -439,6 +455,7 @@ class Level(tool.State): self.plant_groups[i].draw(surface) self.zombie_groups[i].draw(surface) self.bullet_groups[i].draw(surface) + self.drawZombieFreezeTrap(i, surface) for car in self.cars: car.draw(surface) self.head_group.draw(surface)