¿Cómo crear balas en pygame?
Sé que ha habido varios temas sobre esto, pero todavía no puedo entender cómo hacer que mi nave dispare balas ... Quiero agregar a mis balas MOUSEBUTTONDOWN desde la nave mientras se reproduce el efecto de sonido. ¡gracias por la ayuda!
import sys, pygame, pygame.mixer
from pygame.locals import *
pygame.init()
size = width, height = 800, 600
screen = pygame.display.set_mode(size)
clock = pygame.time.Clock()
background = pygame.image.load("bg.png")
ship = pygame.image.load("ship.png")
ship = pygame.transform.scale(ship,(64,64))
shot = pygame.mixer.Sound("shot.wav")
soundin = pygame.mixer.Sound("sound.wav")
soundin.play()
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
elif event.type == MOUSEBUTTONDOWN:
shot.play()
clock.tick(60)
mx,my = pygame.mouse.get_pos()
screen.blit(background,(0,0))
screen.blit(ship,(mx-32,500))
pygame.display.flip()