add plant iceshroom
BIN
resources/graphics/Cards/card_iceshroom.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
resources/graphics/Plants/IceShroom/IceShroom/IceShroom_0.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
resources/graphics/Plants/IceShroom/IceShroom/IceShroom_1.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
resources/graphics/Plants/IceShroom/IceShroom/IceShroom_10.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
resources/graphics/Plants/IceShroom/IceShroom/IceShroom_2.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
resources/graphics/Plants/IceShroom/IceShroom/IceShroom_3.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
resources/graphics/Plants/IceShroom/IceShroom/IceShroom_4.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
resources/graphics/Plants/IceShroom/IceShroom/IceShroom_5.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
resources/graphics/Plants/IceShroom/IceShroom/IceShroom_6.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
resources/graphics/Plants/IceShroom/IceShroom/IceShroom_7.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
resources/graphics/Plants/IceShroom/IceShroom/IceShroom_8.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
resources/graphics/Plants/IceShroom/IceShroom/IceShroom_9.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
@ -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)
|
||||
|
||||
@ -718,3 +718,55 @@ class SunShroom(Plant):
|
||||
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
|
||||
|
||||
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
|
||||
@ -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:
|
||||
@ -92,6 +95,18 @@ 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)
|
||||
|
||||
@ -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
|
||||
@ -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):
|
||||
@ -428,6 +440,10 @@ class Level(tool.State):
|
||||
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)
|
||||
|
||||