大家好 我是毕加锁 (锁!)
今天教大家利用Python制作第一人称小游戏
涉及知识点
1.sprites
2.pygame混音器
3.图章
4.python基础语法
.代码
1发射声
from sprites import *
try:
import pygame
pygame.mixer.init()
fire_sound = pygame.mixer.Sound("audio/发射声.wav")
cricket_sound = pygame.mixer.Sound('audio/cricket.wav')
except:
import sys
input("本程序需要pygame混音器支持以便配音,请先在cmd下用pip install pygame安装此模块。")
2背景
width,height = 480,360
screen = Screen()
screen.bgpic('res/ghosthouse.jpg')
screen.setup(width,height)
batimages = ['res/bat1.png','res/bat2.png']
batindex = 0
bat = Sprite(visible=False,pos=(-50-width//2,100))
bat.dx = 3
bat.dy = 0
bat.alive = True
bat.show()
3射击效果