一.效果呈现
二.主代码
''' Function: 打砖块小游戏 ''' import cfg from modules import breakoutClone '''主函数''' def main(): game = breakoutClone(cfg) game.run() '''run''' if __name__ == '__main__': main()
三.cfg
'''配置文件 ''' import os '''游戏界面一些数值''' SCREENWIDTH = 640 SCREENHEIGHT = 480 BRICKWIDTH = 10 BRICKHEIGHT = 10 PADDLEWIDTH = 60 PADDLEHEIGHT = 12 BALLRADIUS = 8 '''游戏素材路径''' FONTPATH = os.path.join(os.getcwd(), 'resources/font/font.TTF') HITSOUNDPATH = os.path.join(os.getcwd(), 'resources/audios/hit.wav') BGMPATH = os.path.join(os.getcwd(), 'resources/audios/bgm.mp3') LEVELROOTPATH = os.path.join(os.getcwd(), 'resources/levels') LEVELPATHS = [os.path.join(LEVELROOTPATH, '%s.level' % str(i+1)) for i in range(len(os.listdir(LEVELROOTPATH)))] '''一些颜色''' BLACK = (0, 0, 0) WHITE = (255, 255, 255) PINK = (0, 199, 140) PURPLE = (0, 199, 140) YELLOW = (255, 0, 0) BLUE = (0, 0, 0) AQUA = (192, 192, 192)
四.README
# Introduction
https://mp.weixin.qq.com/s/9tNVTA06dFthdugNs3TePA
# Environment
```
OS: Windows10
Python: Python3.5+(have installed necessary dependencies)
```
# Usage
```
Step1:
pip install -r requirements.txt
Step2:
run "python Game18.py"
```
# Game Display
![giphy](demonstration/running.gif)