Added new sfx

This commit is contained in:
theo@manjaro 2021-09-19 21:32:42 +02:00
parent fbe647ad78
commit b81d98fed7
18 changed files with 48 additions and 2 deletions

View File

@ -83,5 +83,4 @@ class GameLoop():
game.screenoffy = (game.screenh-h)/2
game.resizescreenw = w
game.resizescreenh = h
game.pygame.draw.circle(game.realwindow,[255,255,0],game.inputs["mouse"]["pos"],5)
game.screen.blit(game.pygame.transform.scale(game.realwindow,[w,h]),[game.screenoffx,game.screenoffy])

View File

@ -16,6 +16,11 @@ class GameOver(BaseObject):
btn.click = fnBack
game.gameloop.summon(btn)
self.sfxscroll = game.sound_lib["sfx/scorescroll.wav"]
self.sfxscore = game.sound_lib["sfx/score.wav"]
self.sfxtimer = game.lib.Timer(1)
self.depth = -1
# Updating highscore
@ -57,7 +62,8 @@ class GameOver(BaseObject):
def step(self):
self.displayscore+=(self.game.globals["score"]-self.displayscore)*self.game.dt*0.4+self.game.dt*2
update_value = (self.game.globals["score"]-self.displayscore)*self.game.dt*0.4+self.game.dt*2
self.displayscore+= update_value
self.displayscore = min(self.game.globals["score"],self.displayscore)
colorvalue = self.displayscore*0.9
@ -69,7 +75,14 @@ class GameOver(BaseObject):
else: # White to green
self.color = [255-colorvalue,255,255-colorvalue]
# Scroll sfx
if int(self.displayscore)!=int(self.game.globals["score"]):
if self.sfxtimer.tick(min(update_value,0.5)):
self.sfxscroll.play()
if not self.launched and int(self.displayscore)==int(self.game.globals["score"]):
if self.launchtimer.tick(self.game.dt):
# Launch particles
self.launched = True
@ -96,6 +109,8 @@ class GameOver(BaseObject):
vely = random.random()*5+2
self.game.addParticle(sprites,offx,offy,velx=velx,vely=vely,flipx=random.randint(0,1),fps=2)
self.sfxscore.play()
if self.launched:
self.flashtimer.tick(self.game.dt)

View File

@ -16,6 +16,10 @@ class Lemming(BaseObject):
self.cooldown = False
self.cooldowntimer = game.lib.Timer(0.5)
self.sfx = game.getSpriteDir("sfx/pinmik/",ext=".wav",assetdir="sound_lib")
self.sfxtimer = game.lib.Timer(15+random.random()*10)
self.deathsfx = random.choice(game.getSpriteDir("sfx/death/",ext=".wav",assetdir="sound_lib"))
self.handlepause = True
self.scoreratio = 0.3
@ -149,6 +153,14 @@ class Lemming(BaseObject):
sprites = self.game.getSpriteDir("particles/ghost/")
self.game.addParticle(sprites,self.rect.center[0],self.rect.center[1],fps=2,vely=-1)
self.deathsfx.play()
self.game.sound_lib["sfx/death.wav"].play()
# SFX
if self.sfxtimer.tick(self.game.dt):
random.choice(self.sfx).play()
self.sfxtimer = self.game.lib.Timer(15+random.random()*10)
def launch(self):
# Launch itself in the mouse direction
xdiff = self.game.inputs["mouse"]["pos"][0]-self.rect.center[0]
@ -160,6 +172,8 @@ class Lemming(BaseObject):
self.selected = False
self.holdtimer.reset()
self.manager.dash()
def move(self,x,y):
# Remember the digits, pygame rects only move with integers
velx = x+self.restx

View File

@ -26,6 +26,11 @@ class Manager(BaseObject):
# Sky gradients
self.game.gameloop.summon(Skies(game))
# Dash sfx for the pinmiks
self.sfx = game.sound_lib["sfx/dash.wav"]
self.can_sfx = True
self.sfxtimer = game.lib.Timer(0.4)
# Clouds in the background
self.clouds = Clouds(game,game.DISPLAY_WIDTH,speed=30,cameraratio=0.8)
self.cloudsdark = Clouds(game,game.DISPLAY_WIDTH,speed=10,cameraratio=0.4,spritename="cloudsdark.png")
@ -48,7 +53,16 @@ class Manager(BaseObject):
self.game.gameloop.summon(Spawner(self.game,self.tiles,skins=self.skins))
self.game.gameloop.summon(Spawner(self.game,self.tiles,skins=self.skins))
def dash(self):
# Called by pinmiks when dashing
if self.can_sfx:
self.sfx.play()
self.can_sfx = False
def step(self):
if not self.can_sfx:
if self.sfxtimer.tick(self.game.dt):
self.can_sfx = True
lemmings = self.game.gameloop.findname("Lemming")
nblemmings = len(lemmings) + len(self.game.gameloop.findname("Spawner"))
# Updating score

View File

@ -24,6 +24,8 @@ class Spawner(BaseObject):
# Depth updating based on position
self.depth = 1+self.rect[1]/100
game.sound_lib["sfx/fall.wav"].play()
def step(self):
if self.timer.tick(self.game.dt):
lemming = Lemming(self.rect[0],self.rect[1],self.game,speedmargin=self.speedmargin,skin=self.skin)
@ -38,6 +40,8 @@ class Spawner(BaseObject):
self.game.addParticle(sprites,self.rect[0],self.rect[1]+20,velx=-1,vely=-0.5)
self.game.addParticle(sprites,self.rect[0],self.rect[1]+20,velx=1,vely=-0.5)
self.game.sound_lib["sfx/land.wav"].play()
def draw(self):
# Draw the shadow

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.