花了我一个晚上时间整理的Python魂斗罗小游戏源代码

本文分享了用Python编写的魂斗罗小游戏源代码,详细介绍了游戏的操作方式:A/D控制左右,W跳跃,S趴下,J射击,P退出。提供Contra.py和game_functions.py两个关键文件,并给出了完整程序的下载链接。
摘要由CSDN通过智能技术生成

Python魂斗罗小游戏源代码源程序,主程序Contra.py,游戏简易使用说明:A:向左,D:向右,W:跳起,S:趴下,J:射击,P:退出程序。

程序运行截图:

图片

Contra.py

'''公众号:Python代码大全'''import pygameimport sysfrom pygame.locals import *from settings import Settingsfrom game_player import Game_Player import game_functions as gffrom pygame.sprite import Groupfrom game_stats import GameStatsfrom game_boss import Game_Bossfrom button import Button
def run_game():  bg = pygame.image.load("图片/map01.jpeg")  game_settings = Settings()  pos_x = 0#地图移动    pygame.init()  screen = pygame.display.set_mode(    (game_settings.screen_width,game_settings.screen_height))  pygame.display.set_caption("魂斗罗BY Python代码大全")  stats = GameStats(game_settings)  player = Game_Player(game_settings,screen)  bullets = Group()  boss = Group()  enemys = Group()  win_button = Button(game_settings,screen,"YOU WIN")  gf.create_legion(game_settings,screen,enemys)  gf.create_boss(game_settings,screen,player,boss)
  while True:    pygame.mouse.set_visible(False)    gf.check_events(game_settings,screen,player,bullets)    gf.update_player(game_settings,stats,player,enemys)    gf.update_bullet(game_settings,bullets,screen,enemys,boss)      gf.update_enemys(game_settings,enemys)      gf.update_b
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值