Bubbles when underwater

This commit is contained in:
theo@manjaro 2021-11-28 15:17:15 +01:00
parent 6543de826a
commit 7bb10926a2
2 changed files with 9 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

View File

@ -19,6 +19,8 @@ class Player(Movable):
self.spritelanding = game.sprite_lib["player/landing.png"]
self.ouch = game.getchars("Ouch !")
self.bubble = game.getSpriteDir("particles/bubble/")
self.bubbletimer = game.lib.Timer(0.3)
self.landingtimer = 0
self.maxlandtime = 0.15
self.spriteindex = 0
@ -214,6 +216,13 @@ class Player(Movable):
self.jumpsfx.play()
self.jumped = True
super().step() # Actually move
# Spawning bubbles
if self.water:
if self.rect.center[1]>self.water.rect.y and self.bubbletimer.tick((abs(self.horspd)+abs(self.verspd))/30):
offx = self.game.lib.randint(-8,8)
offy = self.game.lib.randint(-8,8)
self.game.addParticle(self.bubble,self.rect.center[0]+offx,self.rect.center[1]+offy,fps=2,depth=3,vely=-0.1)
if self.rect.center[1]>self.game.globals["cameray"]+self.game.globals["camerah"]:
self.die()
for i in self.spikes: