Logo Search packages:      
Sourcecode: castle-combat version File versions  Download package

sound.py

import pygame
from pygame.locals import *
import os
import random

import common

music_files = ('farmor8.xm', 'fdream.xm')
next_file = random.randint(0, len(music_files)-1)

def play_music():
      if pygame.mixer.get_init():
            global next_file
            pygame.mixer.music.load(os.path.join(common.data_path, 'sound', music_files[next_file]))
            pygame.mixer.music.play()
            next_file = (next_file + 1) % len(music_files)
            pygame.mixer.music.set_endevent(common.MUSICEVENT)

if pygame.mixer.get_init():
      cannon = pygame.mixer.Sound(os.path.join(common.data_path, 'sound', 'cannon.wav'))
      wall_hit = pygame.mixer.Sound(os.path.join(common.data_path, 'sound', 'drop.wav'))



Generated by  Doxygen 1.6.0   Back to index