forked from s464965/WMICraft
Merge pull request 'Audio added' (#5) from s464900/WMICraft:audio into audio
Reviewed-on: s464965/WMICraft#5
This commit is contained in:
commit
077574f298
@ -7,6 +7,7 @@ from common.constants import GAME_TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, FPS_COUNT,
|
|||||||
from common.helpers import draw_text
|
from common.helpers import draw_text
|
||||||
from models.knight import Knight
|
from models.knight import Knight
|
||||||
from models.monster import Monster
|
from models.monster import Monster
|
||||||
|
from sound.audioHandler import gamePlaylist
|
||||||
from ui.screens.credits import Credits
|
from ui.screens.credits import Credits
|
||||||
from ui.logs import Logs
|
from ui.logs import Logs
|
||||||
from ui.screens.options import Options
|
from ui.screens.options import Options
|
||||||
@ -35,6 +36,8 @@ class Game:
|
|||||||
click = False
|
click = False
|
||||||
|
|
||||||
def main_menu(self):
|
def main_menu(self):
|
||||||
|
playlist = gamePlaylist()
|
||||||
|
playlist.menuAudio()
|
||||||
while True:
|
while True:
|
||||||
self.screen.blit(self.bg, (0, 0))
|
self.screen.blit(self.bg, (0, 0))
|
||||||
|
|
||||||
@ -92,6 +95,8 @@ class Game:
|
|||||||
knights_list = pygame.sprite.Group()
|
knights_list = pygame.sprite.Group()
|
||||||
knights_list.add(knight1)
|
knights_list.add(knight1)
|
||||||
knights_list.add(knight2)
|
knights_list.add(knight2)
|
||||||
|
playlist = gamePlaylist()
|
||||||
|
playlist.gameAudio()
|
||||||
|
|
||||||
while running:
|
while running:
|
||||||
self.screen.blit(self.bg, (0, 0))
|
self.screen.blit(self.bg, (0, 0))
|
||||||
|
BIN
sound/1.ogg
Normal file
BIN
sound/1.ogg
Normal file
Binary file not shown.
BIN
sound/2mm.ogg
Normal file
BIN
sound/2mm.ogg
Normal file
Binary file not shown.
BIN
sound/3.ogg
Normal file
BIN
sound/3.ogg
Normal file
Binary file not shown.
BIN
sound/4.ogg
Normal file
BIN
sound/4.ogg
Normal file
Binary file not shown.
BIN
sound/5.ogg
Normal file
BIN
sound/5.ogg
Normal file
Binary file not shown.
0
sound/__init__.py
Normal file
0
sound/__init__.py
Normal file
17
sound/audioHandler.py
Normal file
17
sound/audioHandler.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from random import choice
|
||||||
|
from pygame import mixer
|
||||||
|
|
||||||
|
|
||||||
|
class gamePlaylist:
|
||||||
|
wavFiles = ["sound/2mm.ogg", "sound/3.ogg", "sound/4.ogg", "sound/5.ogg"]
|
||||||
|
wavMenu = ["sound/1.ogg"]
|
||||||
|
|
||||||
|
def gameAudio(self):
|
||||||
|
wavRandom = choice(gamePlaylist.wavFiles)
|
||||||
|
mixer.music.load(wavRandom)
|
||||||
|
mixer.music.play()
|
||||||
|
|
||||||
|
def menuAudio(self):
|
||||||
|
w = choice(gamePlaylist.wavMenu)
|
||||||
|
mixer.music.load(w)
|
||||||
|
mixer.music.play(-1)
|
Loading…
Reference in New Issue
Block a user