更新 'ship'
This commit is contained in:
parent
d74670e912
commit
bde30d2268
9
ship
9
ship
|
|
@ -26,7 +26,7 @@ class Ship:
|
||||||
def update(self):
|
def update(self):
|
||||||
"""根据移动标志调整飞船的位置"""
|
"""根据移动标志调整飞船的位置"""
|
||||||
# 更新飞船而不是rect对象的x值
|
# 更新飞船而不是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
|
self.x += self.settings.ship_speed
|
||||||
if self.moving_left and self.rect.left > 0:
|
if self.moving_left and self.rect.left > 0:
|
||||||
self.x -= self.settings.ship_speed
|
self.x -= self.settings.ship_speed
|
||||||
|
|
@ -36,4 +36,9 @@ class Ship:
|
||||||
|
|
||||||
def blitme(self):
|
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)
|
||||||
Loading…
Reference in New Issue