Skip to content

Commit cc671ed

Browse files
author
Aili Shang
committedMay 18, 2017
[Done] Task #0002 添加主py 以及ship.py 两个文件
1 parent 75c36c8 commit cc671ed

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
 

‎Alienware/Alien_invasion.py

+6
Original file line numberDiff line numberDiff line change
@@ -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

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pygame
2+
3+
class Ship():
4+
def __init__(self,screen):
5+
""" 初始化飞船并设置其初始位置 """
6+
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

Comments
 (0)
Please sign in to comment.