You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
35 lines
1.0 KiB
7 months ago
|
# 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]
|