parent
7da24ee07a
commit
ae8f48a8f5
@ -0,0 +1,34 @@
|
||||
# PeaShooter.py
|
||||
import pygame
|
||||
from Plant import Plant
|
||||
|
||||
|
||||
# 豌豆射手类
|
||||
class PeaShooter(Plant):
|
||||
def __init__(self, x, y, grade):
|
||||
super(PeaShooter, self).__init__()
|
||||
|
||||
self.image = pygame.image.load("imgs/peashooter.png")
|
||||
self.rect = self.image.get_rect()
|
||||
self.rect.x = x
|
||||
self.rect.y = y
|
||||
|
||||
self.count = 0
|
||||
|
||||
self.shot_count = 25
|
||||
# 1-4
|
||||
self.grade = grade
|
||||
self.couple = self.get_couple(grade)
|
||||
self.shoot_number = self.couple[0]
|
||||
self.shoot_number_count = self.shoot_number
|
||||
self.bullet_damage = self.couple[1]
|
||||
self.damage = self.shoot_number * self.bullet_damage
|
||||
self.should_fire = False
|
||||
self.should_count_fire = True
|
||||
|
||||
def get_couple(self, grade):
|
||||
# 1*1 2*1 4*1 1*8 2*8 4*8
|
||||
# 1 2 4 8 16 32
|
||||
# 1 2 3 4 5 6
|
||||
lis = [[1, 1], [2, 1], [4, 1], [1, 8], [2, 8], [4, 8]]
|
||||
return lis[grade - 1]
|
Loading…
Reference in new issue