diff --git a/Sunshine.py b/Sunshine.py new file mode 100644 index 0000000..e8d6acc --- /dev/null +++ b/Sunshine.py @@ -0,0 +1,33 @@ +# Sunshine.py +import pygame +from Enemy import Enemy + + +class Sunshine(Enemy): + def __init__(self, x, y): + super(Sunshine, self).__init__() + + self.image = self.scale_image() + + self.rect = self.image.get_rect() + self.rect.x = x + self.rect.y = y + self.money = 1 + self.damage = 0 + + def scale_image(self): + # 原始图片 + original_image = pygame.image.load("imgs/Sunshine.png") + # 缩放比例 + scale_factor = 0.5 + # 计算新尺寸 + original_size = original_image.get_size() + new_size = ( + int(original_size[0] * scale_factor), + int(original_size[1] * scale_factor), + ) + # 执行等比缩放 + scaled_image = pygame.transform.scale(original_image, new_size) + return scaled_image + + # self.image = pygame.image.load("imgs/Sunshine.png")