♥️作者:小刘在这里
♥️每天分享云计算网络运维课堂笔记,努力不一定有收获,但一定会有收获加油!一起努力,共赴美好人生!
♥️夕阳下,是最美的,绽放,愿所有的美好,再疫情结束后如约而至。
目录
一.效果呈现
二,主代码
三.cfg
四.README
'''
Function:
经典坦克大战小游戏
Author:
Charles
微信公众号:
Charles的皮卡丘
'''
import os
import cfg
import pygame
from modules import *
'''主函数'''
def main(cfg):
# 游戏初始化
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((cfg.WIDTH, cfg.HEIGHT))
pygame.display.set_caption(cfg.TITLE)
# 加载游戏素材
sounds = {}
for key, value in cfg.AUDIO_PATHS.items():
sounds[key] = pygame.mixer.Sound(value)
sounds[key].set_volume(1)
# 开始界面
is_dual_mode = gameStartInterface(screen, cfg)
# 关卡数
levelfilepaths = [os.path.join(cfg.LEVELFILEDIR, filename) for filename in sorted(os.listdir(cfg.LEVELFILEDIR))]
# 主循环
for idx, levelfilepath in enumerate(levelfilepaths):
switchLevelIterface(screen, cfg, idx+1)
game_level = GameLevel(idx+1, levelfilepath, sounds, is_dual_mode, cfg)
is_win = game_level.start(screen)
if not is_win: break
is_quit_game = gameEndIterface(screen, cfg, is_win)
return is_quit_game
'''run'''
if __name__ == '__main__':
while True:
is_quit_game = main(cfg)
if is_quit_game:
break
# Introduction
https://mp.weixin.qq.com/s/1xXULpT36P7LTO5HDbjptg
# Environment
```
OS: Windows10
Python: Python3.5+(have installed necessary dependencies)
```
# Usage
```
Step1:
pip install -r requirements.txt
Step2:
run "python Game5.py"
```
# Game Display
![giphy](demonstration/running.gif)
# Introduction
https://mp.weixin.qq.com/s/1xXULpT36P7LTO5HDbjptg
# Environment
```
OS: Windows10
Python: Python3.5+(have installed necessary dependencies)
```
# Usage
```
Step1:
pip install -r requirements.txt
Step2:
run "python Game5.py"
```
# Game Display
![giphy](demonstration/running.gif)
♥️关注,就是我创作的动力
♥️点赞,就是对我最大的认可
♥️这里是小刘,励志用心做好每一篇文章,谢谢大家