Added SFXs

This commit is contained in:
theo@manjaro 2021-11-19 13:42:37 +01:00
parent 4e5f12b967
commit d83e23cd43
18 changed files with 3262 additions and 822 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 29 KiB

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,9 @@ class Spring(Ennemy):
self.rect[2],self.rect[3] = self.sprite.get_width(),round(self.sprite.get_height()/2)
self.spriteindex = 0
self.animspeed = 8
self.sfx = self.game.sound_lib["sfx/spring.wav"]
self.longsfx = self.game.sound_lib["sfx/longspring.wav"]
# Zone in with the player is colliding
# Formatting the angle ( clockwise, in degrees, starting at the top )
@ -57,6 +59,9 @@ class Spring(Ennemy):
force = self.jumpstrength
if self.player.fastfall:
force*=1.5
self.longsfx.play()
else:
self.sfx.play()
self.player.yeet(self.ratiox*force,self.ratioy*force)
self.spriteindex = len(self.sprites)

View File

@ -22,13 +22,15 @@ class Player(Movable):
self.animationspeed = 2.5
self.sprite = self.spritestill
self.rect[2] = self.sprite.get_width()
collisionratio = 0.7
self.rect[2] = self.sprite.get_width()*collisionratio
self.rect[3] = self.sprite.get_height()
self.spriteoffset = self.sprite.get_width()*(1-collisionratio)/2
self.water = self.game.gameloop.findname("Water")[0]
self.hitrect = self.rect.copy()
self.hitrect[2] = round(self.hitrect[2]*0.7)
self.hitrect[2] = round(self.hitrect[2]*1)
self.hitrect[3] = round(self.hitrect[3]*0.7)
self.canhit = False
@ -71,12 +73,18 @@ class Player(Movable):
self.combo = 0
self.combosprites = self.game.getSpriteDir("player/combo/")
self.combosfxs = self.game.getSpriteDir("sfx/combo/",ext=".wav",assetdir="sound_lib")
self.combodefault = self.game.sound_lib["sfx/combo/default.wav"]
self.combotimer = 1
# SFXs
self.landsfx = self.game.sound_lib["sfx/land.wav"]
self.slamsfx = self.game.sound_lib["sfx/slam.wav"]
self.jumpsfx = self.game.sound_lib["sfx/jump.wav"]
def step(self):
if not self.hitpose:
if self.water and self.rect.center[1]>self.water.rect.y: # Reverse gravity underwater
if self.gravityway == 1:
self.gravityway = -1
@ -138,14 +146,17 @@ class Player(Movable):
self.leaptimer = self.leapmaxtimer
self.candash = True
self.canfastfall = True
if self.fastfall:
self.fastfall = 0
# Spawns dust
self.game.addParticle(self.dustparticles,self.rect.right+4,self.rect.center[1]+self.rect[3]/2*self.gravityway,fps=25)
self.game.addParticle(self.dustparticles,self.rect.left-4,self.rect.center[1]+self.rect[3]/2*self.gravityway,fps=25)
if self.verspd!=0:
self.sprite=self.spritelanding
self.landingtimer = self.maxlandtime
if self.fastfall:
self.fastfall = 0
# Spawns dust
self.game.addParticle(self.dustparticles,self.rect.right+4,self.rect.center[1]+self.rect[3]/2*self.gravityway,fps=25)
self.game.addParticle(self.dustparticles,self.rect.left-4,self.rect.center[1]+self.rect[3]/2*self.gravityway,fps=25)
self.slamsfx.play()
else:
self.landsfx.play()
if self.gravityway > 0:
self.verspd=min(0,self.verspd)
else:
@ -185,6 +196,8 @@ class Player(Movable):
self.verspd= self.jump*self.gravityway
if self.leaptimer<0 and not self.onground:
self.verspd = -abs(self.verspd) # Small leap
else:
self.jumpsfx.play()
self.jumped = True
super().step() # Actually move
# Updated hitrect
@ -243,6 +256,9 @@ class Player(Movable):
if self.combo>=1:
index = min(self.combo-1,len(self.combosprites)-1)
self.game.addParticle([self.combosprites[index]],self.rect.center[0],self.rect.top,fps=1)
self.combosfxs[index].play()
else:
self.combodefault.play()
self.combo+=1
self.combotimer = 1
@ -258,4 +274,4 @@ class Player(Movable):
if self.fastfall:
flipy = self.fastfall<0
sprite = self.game.pygame.transform.flip(self.sprite,self.flipx,flipy)
self.game.window.blit(sprite,[self.rect[0]-self.game.globals["camerax"],self.rect[1]-self.game.globals["cameray"]])
self.game.window.blit(sprite,[self.rect[0]-self.game.globals["camerax"]-self.spriteoffset,self.rect[1]-self.game.globals["cameray"]])

View File

@ -76,7 +76,7 @@ class TilesetRenderer(BaseObject):
tilew,tileh = layer["gridCellWidth"],layer["gridCellHeight"]
tileoffx,tileoffy = layer["offsetX"],layer["offsetY"]
nbtilesx,nbtilesy = layer["gridCellsX"],layer["gridCellsY"]
storedlayer = {"offsets":[tileoffx,tileoffy]}
storedlayer = {"offsets":[tileoffx,tileoffy],"name":layer["name"]}
surface = self.game.pygame.Surface((tilew*nbtilesx,tileh*nbtilesy),flags=self.game.pygame.SRCALPHA)
for y in range(len(layer["dataCoords2D"])):
for x in range(len(layer["dataCoords2D"][y])):
@ -111,5 +111,7 @@ class TilesetRenderer(BaseObject):
else:
self.game.log("Erreur",name,"Il manque les collisions, Entity Layer nommé Solids")
self.layers.sort(key=lambda x: x["name"])
self.layers.reverse()
else:
self.game.log("Erreur",name,"Pas de layers")

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.