Combo counter

This commit is contained in:
theo@manjaro 2021-11-18 09:12:09 +01:00
parent 3d7be44d82
commit a149933b28
8 changed files with 20 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

View File

@ -17,6 +17,8 @@ class Ennemy(Movable):
self.particleoffsety = 0
self.canhit = True
self.candie = True
self.cancombo = True
self.dustparticles = game.getSpriteDir("particles/dust/")
@ -37,7 +39,8 @@ class Ennemy(Movable):
hor = -1
self.player.horkb = hor*6
self.player.verkb = self.player.gravityway*-3
if self.player.canhit:
self.player.combo = 0
if self.candie and self.player.canhit:
if self.rect.colliderect(self.player.hitrect):
# Die
self.dead = True
@ -51,6 +54,7 @@ class Ennemy(Movable):
else:
direction = -1
self.player.verspd = self.player.gravity/3*direction
self.player.upcombo()
elif self.respawn:
if self.rect.center[0] < self.game.globals["camerax"]-self.respawnmargin:

View File

@ -78,12 +78,12 @@ class Movable(BaseObject):
result = False
if classic:
for rect in self.collisionrects:
if temprect.colliderect(rect):
if rect!=self.rect and temprect.colliderect(rect):
result = rect
break
if not result and semi:
for rect in self.semirects:
if self.rect.bottom<=rect.top:
if rect!=self.rect and self.rect.bottom<=rect.top:
if temprect.colliderect(rect):
result = rect
break

View File

@ -69,6 +69,9 @@ class Player(Movable):
self.leapmargin = 30 # Vertical margin for the leap
self.gravityway = 1
self.combo = 0
self.combosprites = self.game.getSpriteDir("player/combo/")
def step(self):
if not self.hitpose:
@ -128,6 +131,7 @@ class Player(Movable):
self.fastfall = 0
if self.checkcollisions(0,self.gravityway):
self.onground = True
self.combo = 0
self.leaptimer = self.leapmaxtimer
self.candash = True
self.canfastfall = True
@ -226,6 +230,15 @@ class Player(Movable):
self.game.globals["camerax"] = self.rect.center[0]-self.game.globals["cameraw"]/2
self.game.globals["cameray"] = self.rect.center[1]-self.game.globals["camerah"]/2
def upcombo(self):
# Up the combo and spawn particles
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.combo+=1
def draw(self):
flipy = (self.gravityway<0 and not self.leaptimer<0)
if self.fastfall: