add threepeashooter plant
BIN
resources/graphics/Cards/card_threepeashooter.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_0.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_1.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_10.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_11.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_12.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_13.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_14.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_15.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_2.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_3.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_4.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_5.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_6.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_7.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_8.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
resources/graphics/Plants/Threepeater/Threepeater_9.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
@ -4,10 +4,10 @@ import pygame as pg
|
|||||||
from .. import tool
|
from .. import tool
|
||||||
from .. import constants as c
|
from .. import constants as c
|
||||||
|
|
||||||
card_name_list = [c.CARD_SUNFLOWER, c.CARD_PEASHOOTER, c.CARD_SNOWPEASHOOTER, c.CARD_WALLNUT, c.CARD_CHERRYBOMB]
|
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]
|
plant_name_list = [c.SUNFLOWER, c.PEASHOOTER, c.SNOWPEASHOOTER, c.WALLNUT, c.CHERRYBOMB, c.THREEPEASHOOTER]
|
||||||
plant_sun_list = [50, 100, 175, 50, 150]
|
plant_sun_list = [50, 100, 175, 50, 150, 325]
|
||||||
card_list = [0, 1, 2, 3, 4]
|
card_list = [0, 1, 2, 3, 4, 5]
|
||||||
|
|
||||||
class Card():
|
class Card():
|
||||||
def __init__(self, x, y, name_index):
|
def __init__(self, x, y, name_index):
|
||||||
|
|||||||
@ -5,7 +5,7 @@ from .. import tool
|
|||||||
from .. import constants as c
|
from .. import constants as c
|
||||||
|
|
||||||
class Bullet(pg.sprite.Sprite):
|
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)
|
pg.sprite.Sprite.__init__(self)
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -15,7 +15,9 @@ class Bullet(pg.sprite.Sprite):
|
|||||||
self.image = self.frames[self.frame_index]
|
self.image = self.frames[self.frame_index]
|
||||||
self.rect = self.image.get_rect()
|
self.rect = self.image.get_rect()
|
||||||
self.rect.x = x - 40
|
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.x_vel = 4
|
||||||
self.damage = damage
|
self.damage = damage
|
||||||
self.ice = ice
|
self.ice = ice
|
||||||
@ -45,6 +47,8 @@ class Bullet(pg.sprite.Sprite):
|
|||||||
def update(self, game_info):
|
def update(self, game_info):
|
||||||
self.current_time = game_info[c.CURRENT_TIME]
|
self.current_time = game_info[c.CURRENT_TIME]
|
||||||
if self.state == c.FLY:
|
if self.state == c.FLY:
|
||||||
|
if self.rect.y != self.dest_y:
|
||||||
|
self.rect.y += self.y_vel
|
||||||
self.rect.x += self.x_vel
|
self.rect.x += self.x_vel
|
||||||
if self.rect.x > c.SCREEN_WIDTH:
|
if self.rect.x > c.SCREEN_WIDTH:
|
||||||
self.kill()
|
self.kill()
|
||||||
@ -183,7 +187,29 @@ class PeaShooter(Plant):
|
|||||||
|
|
||||||
def attacking(self):
|
def attacking(self):
|
||||||
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, 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
|
self.shoot_timer = self.current_time
|
||||||
|
|
||||||
def setAttack(self):
|
def setAttack(self):
|
||||||
@ -196,7 +222,8 @@ class SnowPeaShooter(Plant):
|
|||||||
|
|
||||||
def attacking(self):
|
def attacking(self):
|
||||||
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, 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
|
self.shoot_timer = self.current_time
|
||||||
|
|
||||||
def setAttack(self):
|
def setAttack(self):
|
||||||
|
|||||||
@ -64,6 +64,7 @@ PEASHOOTER = 'Peashooter'
|
|||||||
SNOWPEASHOOTER = 'SnowPea'
|
SNOWPEASHOOTER = 'SnowPea'
|
||||||
WALLNUT = 'WallNut'
|
WALLNUT = 'WallNut'
|
||||||
CHERRYBOMB = 'CherryBomb'
|
CHERRYBOMB = 'CherryBomb'
|
||||||
|
THREEPEASHOOTER = 'Threepeater'
|
||||||
CHERRY_BOOM_IMAGE = 'Boom'
|
CHERRY_BOOM_IMAGE = 'Boom'
|
||||||
|
|
||||||
PLANT_HEALTH = 5
|
PLANT_HEALTH = 5
|
||||||
@ -76,12 +77,15 @@ FLOWER_SUN_INTERVAL = 22000
|
|||||||
SUN_LIVE_TIME = 7000
|
SUN_LIVE_TIME = 7000
|
||||||
SUN_VALUE = 25
|
SUN_VALUE = 25
|
||||||
|
|
||||||
|
ICE_SLOW_TIME = 2000
|
||||||
|
|
||||||
#PLANT CARD INFO
|
#PLANT CARD INFO
|
||||||
CARD_SUNFLOWER = 'card_sunflower'
|
CARD_SUNFLOWER = 'card_sunflower'
|
||||||
CARD_PEASHOOTER = 'card_peashooter'
|
CARD_PEASHOOTER = 'card_peashooter'
|
||||||
CARD_SNOWPEASHOOTER = 'card_snowpea'
|
CARD_SNOWPEASHOOTER = 'card_snowpea'
|
||||||
CARD_WALLNUT = 'card_wallnut'
|
CARD_WALLNUT = 'card_wallnut'
|
||||||
CARD_CHERRYBOMB = 'card_cherrybomb'
|
CARD_CHERRYBOMB = 'card_cherrybomb'
|
||||||
|
CARD_THREEPEASHOOTER = 'card_threepeashooter'
|
||||||
|
|
||||||
#BULLET INFO
|
#BULLET INFO
|
||||||
BULLET_PEA = 'PeaNormal'
|
BULLET_PEA = 'PeaNormal'
|
||||||
|
|||||||
@ -155,6 +155,8 @@ class Level(tool.State):
|
|||||||
self.plant_groups[map_y].add(plant.WallNut(x, y))
|
self.plant_groups[map_y].add(plant.WallNut(x, y))
|
||||||
elif self.plant_name == c.CHERRYBOMB:
|
elif self.plant_name == c.CHERRYBOMB:
|
||||||
self.plant_groups[map_y].add(plant.CherryBomb(x, y))
|
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.menubar.decreaseSunValue(self.plant_cost)
|
||||||
self.map.setMapGridType(map_x, map_y, c.MAP_EXIST)
|
self.map.setMapGridType(map_x, map_y, c.MAP_EXIST)
|
||||||
@ -241,9 +243,25 @@ class Level(tool.State):
|
|||||||
plant.setAttack()
|
plant.setAttack()
|
||||||
if plant.health <= 0:
|
if plant.health <= 0:
|
||||||
self.killPlant(plant)
|
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:
|
else:
|
||||||
for plant in self.plant_groups[i]:
|
for plant in self.plant_groups[i]:
|
||||||
if plant.state == c.ATTACK:
|
if plant.state == c.ATTACK:
|
||||||
|
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()
|
plant.setIdle()
|
||||||
if plant.health <= 0:
|
if plant.health <= 0:
|
||||||
self.killPlant(plant)
|
self.killPlant(plant)
|
||||||
|
|||||||