資源簡(jiǎn)介
利用面向?qū)ο蟮姆绞綄?shí)現(xiàn)邏輯層顯示層分離,用pygame完成響應(yīng)鍵盤(pán)敲擊速度的游戲:隨機(jī)截取一段英文短文。統(tǒng)計(jì)一分鐘內(nèi)用戶(hù)對(duì)照輸入的正確的單詞數(shù)量并實(shí)時(shí)根據(jù)鍵盤(pán)敲擊的速度顯示屏幕背景色。越快屏幕顏色就越偏向綠色。越慢越偏向紅色。ps:如果輸入完了一整段一分鐘還沒(méi)到就換下一段

代碼片段和文件信息
#?-*-?coding:?utf-8?-*-
import?pygame
class?Caption(pygame.sprite.Sprite):
????‘‘‘
????實(shí)時(shí)顯示打字性能
????‘‘‘
????def?__init__(self):
????????pygame.sprite.Sprite.__init__(self)
????????self.text?=?“Speed:?%.1f/min?correct?words:?%s/%s?time:?%d?s“?%?(0?0?0?60)
????????self.update()
????def?update(self):
????????self.image?=?pygame.font.Font(None?26).render(self.text?1?(0?0?0))
????????self.rect?=?self.image.get_rect()
????def?setText(self?speed?words?corrWords?countDownTime):
????????self.text?=?“Speed:?%.1f/min?correct?words:?%s/%s?time:?%d?s“?%?(
????????????speed?corrWords?words?countDownTime)
????#?def?setText2(self?corrWords):
????#?????self.text2?=?“一分鐘共打?qū)卧~數(shù):&s個(gè)“?%corrWords
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2019-07-04?18:32??typeGame\
?????文件????????1203??2018-12-13?15:00??typeGame\.gitignore
?????目錄???????????0??2019-07-04?18:34??typeGame\.idea\
?????文件?????????686??2019-07-04?17:24??typeGame\.idea\misc.xm
?????文件?????????268??2019-07-04?17:23??typeGame\.idea\modules.xm
?????文件?????????459??2019-07-04?17:24??typeGame\.idea\typeGame.iml
?????文件???????32151??2019-07-04?18:34??typeGame\.idea\workspace.xm
?????文件?????????130??2019-07-04?17:30??typeGame\README.md
?????目錄???????????0??2019-07-04?18:31??typeGame\__pycache__\
?????文件????????1086??2019-07-04?18:31??typeGame\__pycache__\captions.cpython-36.pyc
?????文件????????3075??2019-07-04?18:13??typeGame\__pycache__\inputarea.cpython-36.pyc
?????文件?????????937??2019-07-04?17:47??typeGame\__pycache__\textgenerator.cpython-36.pyc
?????文件?????????748??2019-07-04?18:31??typeGame\captions.py
?????目錄???????????0??2019-07-04?17:40??typeGame\files\
?????文件????????3071??2019-07-04?17:40??typeGame\files\speed.txt
?????文件????????3301??2019-07-04?18:13??typeGame\inputarea.py
?????文件??????????23??2018-12-13?15:00??typeGame\requirements.txt
?????文件????????2610??2019-07-04?18:32??typeGame\run.py
?????文件?????????610??2019-07-04?17:41??typeGame\textgenerator.py
評(píng)論
共有 條評(píng)論