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 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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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'
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||