diff --git a/resources/graphics/Cards/card_threepeashooter.png b/resources/graphics/Cards/card_threepeashooter.png new file mode 100644 index 0000000..e71fc31 Binary files /dev/null and b/resources/graphics/Cards/card_threepeashooter.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_0.png b/resources/graphics/Plants/Threepeater/Threepeater_0.png new file mode 100644 index 0000000..da1721f Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_0.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_1.png b/resources/graphics/Plants/Threepeater/Threepeater_1.png new file mode 100644 index 0000000..e3f78e4 Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_1.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_10.png b/resources/graphics/Plants/Threepeater/Threepeater_10.png new file mode 100644 index 0000000..919624b Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_10.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_11.png b/resources/graphics/Plants/Threepeater/Threepeater_11.png new file mode 100644 index 0000000..e8ca050 Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_11.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_12.png b/resources/graphics/Plants/Threepeater/Threepeater_12.png new file mode 100644 index 0000000..838511f Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_12.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_13.png b/resources/graphics/Plants/Threepeater/Threepeater_13.png new file mode 100644 index 0000000..9fe1065 Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_13.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_14.png b/resources/graphics/Plants/Threepeater/Threepeater_14.png new file mode 100644 index 0000000..b7f4bc1 Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_14.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_15.png b/resources/graphics/Plants/Threepeater/Threepeater_15.png new file mode 100644 index 0000000..ff07c45 Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_15.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_2.png b/resources/graphics/Plants/Threepeater/Threepeater_2.png new file mode 100644 index 0000000..0c07431 Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_2.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_3.png b/resources/graphics/Plants/Threepeater/Threepeater_3.png new file mode 100644 index 0000000..712177c Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_3.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_4.png b/resources/graphics/Plants/Threepeater/Threepeater_4.png new file mode 100644 index 0000000..fd8c69b Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_4.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_5.png b/resources/graphics/Plants/Threepeater/Threepeater_5.png new file mode 100644 index 0000000..938c59c Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_5.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_6.png b/resources/graphics/Plants/Threepeater/Threepeater_6.png new file mode 100644 index 0000000..a22ef84 Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_6.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_7.png b/resources/graphics/Plants/Threepeater/Threepeater_7.png new file mode 100644 index 0000000..1715efe Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_7.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_8.png b/resources/graphics/Plants/Threepeater/Threepeater_8.png new file mode 100644 index 0000000..20d6e84 Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_8.png differ diff --git a/resources/graphics/Plants/Threepeater/Threepeater_9.png b/resources/graphics/Plants/Threepeater/Threepeater_9.png new file mode 100644 index 0000000..a393108 Binary files /dev/null and b/resources/graphics/Plants/Threepeater/Threepeater_9.png differ diff --git a/source/component/menubar.py b/source/component/menubar.py index c10f40a..d10d746 100644 --- a/source/component/menubar.py +++ b/source/component/menubar.py @@ -4,10 +4,10 @@ import pygame as pg from .. import tool from .. import constants as c -card_name_list = [c.CARD_SUNFLOWER, c.CARD_PEASHOOTER, c.CARD_SNOWPEASHOOTER, c.CARD_WALLNUT, c.CARD_CHERRYBOMB] -plant_name_list = [c.SUNFLOWER, c.PEASHOOTER, c.SNOWPEASHOOTER, c.WALLNUT, c.CHERRYBOMB] -plant_sun_list = [50, 100, 175, 50, 150] -card_list = [0, 1, 2, 3, 4] +card_name_list = [c.CARD_SUNFLOWER, c.CARD_PEASHOOTER, c.CARD_SNOWPEASHOOTER, c.CARD_WALLNUT, c.CARD_CHERRYBOMB, c.CARD_THREEPEASHOOTER] +plant_name_list = [c.SUNFLOWER, c.PEASHOOTER, c.SNOWPEASHOOTER, c.WALLNUT, c.CHERRYBOMB, c.THREEPEASHOOTER] +plant_sun_list = [50, 100, 175, 50, 150, 325] +card_list = [0, 1, 2, 3, 4, 5] class Card(): def __init__(self, x, y, name_index): diff --git a/source/component/plant.py b/source/component/plant.py index ee35ba1..457f534 100644 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -5,7 +5,7 @@ from .. import tool from .. import constants as c class Bullet(pg.sprite.Sprite): - def __init__(self, x, y, name, damage, ice): + def __init__(self, x, start_y, dest_y, name, damage, ice): pg.sprite.Sprite.__init__(self) self.name = name @@ -15,7 +15,9 @@ class Bullet(pg.sprite.Sprite): self.image = self.frames[self.frame_index] self.rect = self.image.get_rect() self.rect.x = x - 40 - self.rect.y = y + self.rect.y = start_y + self.dest_y = dest_y + self.y_vel = 4 if (dest_y > start_y) else -4 self.x_vel = 4 self.damage = damage self.ice = ice @@ -45,6 +47,8 @@ class Bullet(pg.sprite.Sprite): def update(self, game_info): self.current_time = game_info[c.CURRENT_TIME] if self.state == c.FLY: + if self.rect.y != self.dest_y: + self.rect.y += self.y_vel self.rect.x += self.x_vel if self.rect.x > c.SCREEN_WIDTH: self.kill() @@ -183,7 +187,29 @@ class PeaShooter(Plant): def attacking(self): if (self.current_time - self.shoot_timer) > 2000: - self.bullet_group.add(Bullet(self.rect.right, self.rect.y, c.BULLET_PEA, c.BULLET_DAMAGE_NORMAL, False)) + self.bullet_group.add(Bullet(self.rect.right, self.rect.y, self.rect.y, + c.BULLET_PEA, c.BULLET_DAMAGE_NORMAL, False)) + self.shoot_timer = self.current_time + + def setAttack(self): + self.state = c.ATTACK + +class ThreePeaShooter(Plant): + def __init__(self, x, y, bullet_groups, map_y): + Plant.__init__(self, x, y, c.THREEPEASHOOTER, c.PLANT_HEALTH, None) + self.shoot_timer = 0 + self.map_y = map_y + self.bullet_groups = bullet_groups + + def attacking(self): + if (self.current_time - self.shoot_timer) > 2000: + for i in range(3): + tmp_y = self.map_y + (i - 1) + if tmp_y < 0 or tmp_y >= c.GRID_Y_LEN: + continue + dest_y = self.rect.y + (i - 1) * c.GRID_Y_SIZE + self.bullet_groups[tmp_y].add(Bullet(self.rect.right, self.rect.y, dest_y, + c.BULLET_PEA, c.BULLET_DAMAGE_NORMAL, False)) self.shoot_timer = self.current_time def setAttack(self): @@ -196,7 +222,8 @@ class SnowPeaShooter(Plant): def attacking(self): if (self.current_time - self.shoot_timer) > 2000: - self.bullet_group.add(Bullet(self.rect.right, self.rect.y, c.BULLET_PEA_ICE, c.BULLET_DAMAGE_NORMAL, True)) + self.bullet_group.add(Bullet(self.rect.right, self.rect.y, self.rect.y, + c.BULLET_PEA_ICE, c.BULLET_DAMAGE_NORMAL, True)) self.shoot_timer = self.current_time def setAttack(self): diff --git a/source/constants.py b/source/constants.py index 0fb3114..5f32bbc 100644 --- a/source/constants.py +++ b/source/constants.py @@ -64,6 +64,7 @@ PEASHOOTER = 'Peashooter' SNOWPEASHOOTER = 'SnowPea' WALLNUT = 'WallNut' CHERRYBOMB = 'CherryBomb' +THREEPEASHOOTER = 'Threepeater' CHERRY_BOOM_IMAGE = 'Boom' PLANT_HEALTH = 5 @@ -76,12 +77,15 @@ FLOWER_SUN_INTERVAL = 22000 SUN_LIVE_TIME = 7000 SUN_VALUE = 25 +ICE_SLOW_TIME = 2000 + #PLANT CARD INFO CARD_SUNFLOWER = 'card_sunflower' CARD_PEASHOOTER = 'card_peashooter' CARD_SNOWPEASHOOTER = 'card_snowpea' CARD_WALLNUT = 'card_wallnut' CARD_CHERRYBOMB = 'card_cherrybomb' +CARD_THREEPEASHOOTER = 'card_threepeashooter' #BULLET INFO BULLET_PEA = 'PeaNormal' diff --git a/source/state/level.py b/source/state/level.py index 2c3ab7f..f7d41c1 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -155,6 +155,8 @@ class Level(tool.State): self.plant_groups[map_y].add(plant.WallNut(x, y)) elif self.plant_name == c.CHERRYBOMB: self.plant_groups[map_y].add(plant.CherryBomb(x, y)) + elif self.plant_name == c.THREEPEASHOOTER: + self.plant_groups[map_y].add(plant.ThreePeaShooter(x, y, self.bullet_groups, map_y)) self.menubar.decreaseSunValue(self.plant_cost) self.map.setMapGridType(map_x, map_y, c.MAP_EXIST) @@ -241,10 +243,26 @@ class Level(tool.State): plant.setAttack() if plant.health <= 0: self.killPlant(plant) + if (i-1) >= 0: + for plant in self.plant_groups[i-1]: + if plant.name == c.THREEPEASHOOTER and plant.state == c.IDLE: + plant.setAttack() + if (i+1) < self.map_y_len: + for plant in self.plant_groups[i+1]: + if plant.name == c.THREEPEASHOOTER and plant.state == c.IDLE: + plant.setAttack() else: for plant in self.plant_groups[i]: if plant.state == c.ATTACK: - plant.setIdle() + if plant.name == c.THREEPEASHOOTER: + if (i-1) >= 0 and len(self.zombie_groups[i-1]) > 0: + pass + elif (i+1) < self.map_y_len and len(self.zombie_groups[i+1]) > 0: + pass + else: + plant.setIdle() + else: + plant.setIdle() if plant.health <= 0: self.killPlant(plant)