添加 'alien'

This commit is contained in:
201110504 2021-06-19 22:18:11 +08:00
parent 6515e0ae86
commit 696d02b3d2
1 changed files with 21 additions and 0 deletions

21
alien Normal file
View File

@ -0,0 +1,21 @@
import pygame
from pygame.sprite import Sprite
class Alien(Sprite):
"""表示单个外星人的类"""
def __init__(self,ai_game):
"""初始化外星人并设置其起始位置"""
super().__init__()
self.screen = ai_game.screen
# 加载外星人图像并设置其rect属性
self.image = pygame.image.load('images/alien.bmp')
self.rect = self.image.get_rect()
# 每个外星人最初都在屏幕左上角附近
self.rect.x = self.rect.width
self.rect.y = self.rect.height
# 存储外星人的精确水平位置
self.x = float(self.rect.x)