def do_sound(self, id):
		width_over_two = GAME_WIDTH // 2
		mx, my = self.cursor
		if id == 'sfx_volume':
			if mx < (width_over_two - 20) and self.mouse == 0: pass
			else:
				MAGIC_POTATO.set_sound_volume((mx - width_over_two) // 2)
				self.sfx_vol = MAGIC_POTATO.get_sound_volume()
		elif id == 'music_volume':
			if mx < (width_over_two - 20) and self.mouse == 0: pass
			else:
				MAGIC_POTATO.set_music_volume((mx - width_over_two) // 2)
				self.music_vol = MAGIC_POTATO.get_music_volume()
	def __init__(self, background_scene):
		self.next = None
		self.bg = background_scene
		self.buttons = {
			'full_screen': [0] * 4,
			'sfx_volume': [0] * 4,
			'music_volume': [0] * 4,
			'back': [0] * 4
		}
		if self.bg != None:
			self.buttons.update({'main_menu': [0] * 4})

		self.cursor = (0, 0)
		self.currently_over = None

		self.sfx_vol = MAGIC_POTATO.get_sound_volume()
		self.music_vol = MAGIC_POTATO.get_music_volume()
		
		self.mouse = 0
		self.over = None
Пример #3
0
	def _play_sound(self, id):
		if id != None:
			snd = self.sounds.get(id, None)
			if snd == None:
				snd = []
				for t in id.split(','):
					t = t.strip()
					file = id
					if not file.endswith('.wav'):
						file += '.ogg'
					snd.append(pygame.mixer.Sound('sfx' + os.sep + file))
				self.sounds[id] = snd
			
			sound = None
			if len(snd) == 1:
				sound = snd[0]
			elif len(snd) > 1:
				sound = random.choice(snd)
			
			if sound != None:
				sound.set_volume(MAGIC_POTATO.get_sound_volume())
				sound.play()