Added background music, background music is currently randomly selected between 2 audio files on startup
This commit is contained in:
20
game.py
20
game.py
@ -40,7 +40,12 @@ class Game(gameUtils.Game):
|
||||
self.gunSpin = pygame.mixer.Sound("./assets/gun-spin.mp3")
|
||||
self.gunLoad = pygame.mixer.Sound("./assets/gun-load.mp3")
|
||||
self.gunCyclinderStop = pygame.mixer.Sound("./assets/gun-cylinder-stop.mp3")
|
||||
|
||||
|
||||
#Background Music commands
|
||||
self.unloadMusic = pygame.mixer.music.unload
|
||||
self.stopMusic = pygame.mixer.music.stop
|
||||
self.playMusic = pygame.mixer.music.play
|
||||
|
||||
#self.gun = pygame.load_animation('./assets/gun-spin.webp')
|
||||
self.gunFlash = pygame.image.load("./assets/muzzleflash.png")
|
||||
|
||||
@ -63,6 +68,19 @@ class Game(gameUtils.Game):
|
||||
|
||||
self.gunScale = min(self.size[1]/self.gunh,self.size[0]/self.gunw) #calculates how to scale the gun so that it stays on the screen
|
||||
|
||||
|
||||
#Selects random music to play at the start of the game, might change because I just threw this together.
|
||||
#I feel horrible writing this code this feels super unoptimised :c
|
||||
if self.musicNumber == 1:
|
||||
pygame.mixer.music.load("./assets/surrounded.ogg")
|
||||
self.playMusic(-1)
|
||||
pygame.mixer.music.set_volume(0.5)
|
||||
if self.musicNumber == 2:
|
||||
pygame.mixer.music.load("./assets/twiceoritsluck.ogg")
|
||||
self.playMusic(-1)
|
||||
pygame.mixer.music.set_volume(0.5)
|
||||
|
||||
|
||||
def fire(self):#LETS GO GAMBLING
|
||||
if randint(1,6) == 6:
|
||||
self.playSound(self.gunShot)
|
||||
|
||||
Reference in New Issue
Block a user