python小游戏——塔防小游戏代码开源

♥️作者:小刘在这里

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

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

目录


一.效果呈现

python小游戏——塔防小游戏代码开源

二.主代码

'''
Function:
    塔防游戏
源码基地:#959755565#
'''
import cfg
import pygame
from modules import *


'''主函数'''
def main():
    pygame.init()
    pygame.mixer.init()
    pygame.mixer.music.load(cfg.AUDIOPATHS['bgm'])
    pygame.mixer.music.play(-1, 0.0)
    pygame.mixer.music.set_volume(0.25)
    screen = pygame.display.set_mode(cfg.SCREENSIZE)
    pygame.display.set_caption("保卫基地——塔防游戏 ")
    # 调用游戏开始界面
    start_interface = StartInterface(cfg)
    is_play = start_interface.update(screen)
    if not is_play:
        return
    # 调用游戏界面
    while True:
        choice_interface = ChoiceInterface(cfg)
        map_choice, difficulty_choice = choice_interface.update(screen)
        game_interface = GamingInterface(cfg)
        game_interface.start(screen, map_path=cfg.MAPPATHS[str(map_choice)], difficulty_path=cfg.DIFFICULTYPATHS[str(difficulty_choice)])
        end_interface = EndInterface(cfg)
        end_interface.update(screen)


'''run'''
if __name__ == '__main__':
    main()

三.cfg

# Introduction
https://mp.weixin.qq.com/s/mcnN3dF5tzWlRg91cnWTEw

# Environment
“`
OS: Windows10
Python: Python3.5+(have installed necessary dependencies)
“`

# Usage
“`
Step1:
pip install -r requirements.txt
Step2:
run "python Game8.py"
“`

# Game Display
![giphy](demonstration/running.gif)

四.README

# Introduction
https://mp.weixin.qq.com/s/mcnN3dF5tzWlRg91cnWTEw

# Environment
“`
OS: Windows10
Python: Python3.5+(have installed necessary dependencies)
“`

# Usage
“`
Step1:
pip install -r requirements.txt
Step2:
run "python Game8.py"
“`

# Game Display
![giphy](demonstration/running.gif)

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

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

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

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
青葱年少的头像青葱年少普通用户
上一篇 2023年3月4日 下午9:23
下一篇 2023年3月4日 下午9:24

相关推荐