We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 75c36c8 commit cc671edCopy full SHA for cc671ed
Alienware/Alien_invasion.py
@@ -0,0 +1,6 @@
1
+from setting import Settings
2
+from Ship import Ship
3
+
4
5
+def run_game():
6
+ pygame.display.set_caption("Alien Invasion")
Alienware/Ship.py
@@ -0,0 +1,22 @@
+import pygame
+class Ship():
+ def __init__(self,screen):
+ """ 初始化飞船并设置其初始位置 """
+ self.screen = screen
7
8
+ # 加载飞船图像并获取外接矩形
9
10
+ self.image = pygame.image.load('images/ship.bmp')
11
+ self.rect = self.image.get_rect()
12
+ self.screen_rect = screen.get_rect()
13
14
+ # 将飞船放在屏幕底部
15
+ self.rect.centerx = slef.screen_rect.cneterx
16
+ self.rect.bottom = self.screen_rect.bottom
17
18
+ def blitem(self):
19
+ """ 在指定位置设置绘制飞船"""
20
+ self.screen.blit(self.image,self.rect)
21
22
0 commit comments