91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

這里給大家親測可用的《python編程:從入門到實踐》13.1-14.3的全部代碼。具體的代碼可能會和書上的稍有不同,主要是計分環節的前面加了“highest”、“current”、“level”的字符串,其他基本是相同的。代碼中會有許多紅色的打印注釋,是用于調試尋找bug時留下的,大家不用過于在意。下面是代碼運行以后的效果。

資源截圖

代碼片段和文件信息

import?pygame
from?pygame.sprite?import?Sprite

class?Alien(Sprite):
????“““表示單個外星人的類“““

????def?__init__(selfai_settingsscreen):
????????“““初始化外星人并設置其起始位置“““
????????super().__init__()
????????self.screen=screen
????????self.ai_settings=ai_settings

????????#加載外星人的圖像,并設置其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)

????def?check_edges(self):
????????“““如果外星人位于屏幕邊緣,就返回True“““
????????screen_rect=self.screen.get_rect()
????????if?self.rect.right>screen_rect.right:
????????????return?True
????????elif?self.rect.left<=0:
????????????return?True

????def?update(self):
????????“““向左或者向右移動外星人“““
????????self.x+=(self.ai_settings.alien_speed_factor*
?????????????????self.ai_settings.fleet_direction)
????????self.rect.x=self.x
????????

????def?blitme(self):
????????“““在指定位置繪制外星人“““
????????self.screen.blit(self.imageself.rect)

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-09-29?18:28??__pycache__\
?????文件????????1471??2018-08-30?14:15??__pycache__\alien.cpython-37.pyc
?????文件????????1244??2018-08-27?13:49??__pycache__\bullet.cpython-37.pyc
?????文件????????1233??2018-08-30?16:52??__pycache__\button.cpython-37.pyc
?????文件????????6155??2018-09-29?18:23??__pycache__\game_functions.cpython-37.pyc
?????文件?????????827??2018-09-29?15:28??__pycache__\game_stats.cpython-37.pyc
?????文件????????2707??2018-09-29?18:26??__pycache__\scoreboard.cpython-37.pyc
?????文件????????1442??2018-09-28?15:35??__pycache__\settings.cpython-37.pyc
?????文件????????1369??2018-09-29?18:28??__pycache__\ship.cpython-37.pyc
?????文件????????1292??2018-08-30?14:02??alien.py
?????文件????????1667??2018-09-29?15:42??alien_invasion.py
?????文件????????1134??2018-08-27?13:49??bullet.py
?????文件????????1197??2018-08-30?16:52??button.py
?????文件????????9028??2018-09-29?18:23??game_functions.py
?????文件?????????597??2018-09-29?15:17??game_stats.py
?????目錄???????????0??2018-08-28?16:36??images\
?????文件????????2144??2018-08-28?16:36??images\alien.bmp
?????文件????????6048??2018-08-28?16:35??images\alien1.bmp
?????文件????????4222??2018-08-27?10:42??images\ship.bmp
?????文件???????23467??2018-08-20?12:59??images\ship_sourceimg.bmp
?????文件?????4385142??2018-08-10?16:43??pygame-1.9.4-cp37-cp37m-win_amd64.whl
?????文件????????3635??2018-09-29?18:26??scoreboard.py
?????文件????????1901??2018-09-28?15:32??settings.py
?????文件????????1486??2018-09-29?18:28??ship.py

評論

共有 條評論