更新 'ship'

This commit is contained in:
201110504 2021-06-20 22:43:07 +08:00
parent d74670e912
commit bde30d2268
1 changed files with 7 additions and 2 deletions

9
ship
View File

@ -26,7 +26,7 @@ class Ship:
def update(self):
"""根据移动标志调整飞船的位置"""
# 更新飞船而不是rect对象的x值
if self.moving_right and self.rect.right < self.screen_rect.right:
if self.moving_right and self.rect.right < self.screen_rect.right:
self.x += self.settings.ship_speed
if self.moving_left and self.rect.left > 0:
self.x -= self.settings.ship_speed
@ -36,4 +36,9 @@ class Ship:
def blitme(self):
"""在指定位置绘制飞船"""
self.screen.blit(self.image, self.rect)
self.screen.blit(self.image, self.rect)
def center_ship(self):
"""让飞船在屏幕底端局中"""
self.rect.midbottom = self.screen_rect.midbottom
self.x = float(self.rect.x)