失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > python小游戏——怀念经典坦克大战代码

python小游戏——怀念经典坦克大战代码

时间:2021-12-23 06:15:54

相关推荐

python小游戏——怀念经典坦克大战代码

♥️作者:小刘在这里

♥️每天分享云计算网络运维课堂笔记,努力不一定有回报,但一定会有收获加油!一起努力,共赴美好人生!

♥️夕阳下,是最美的,绽放,愿所有的美好,再疫情结束后如约而至。

目录

一.效果呈现

二,主代码

三.cfg

四.README

一.效果呈现

二,主代码

'''Function:经典坦克大战小游戏Author:Charles微信公众号:Charles的皮卡丘'''import osimport cfgimport pygamefrom 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: breakis_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

三.cfg

# Introduction

https://mp./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)

四.README

# Introduction

https://mp./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)

♥️关注,就是我创作的动力

♥️点赞,就是对我最大的认可

♥️这里是小刘,励志用心做好每一篇文章,谢谢大家

如果觉得《python小游戏——怀念经典坦克大战代码》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。