More beautifull collision check
This commit is contained in:
+1
-2
@@ -240,9 +240,8 @@ class Drakora():
|
|||||||
else:
|
else:
|
||||||
return 300
|
return 300
|
||||||
|
|
||||||
|
|
||||||
def collideCheck(self):
|
def collideCheck(self):
|
||||||
if sum([1 if pygame.sprite.spritecollideany(i, self.enemies) else 0 for i in self.player.getCollisionBoxes()]):
|
if pygame.sprite.groupcollide(self.player.getCollisionBoxes(), self.enemies, None, None):
|
||||||
if not self.isGodmode: self.isGameOver = True
|
if not self.isGodmode: self.isGameOver = True
|
||||||
|
|
||||||
if self.player.isOnFloor:
|
if self.player.isOnFloor:
|
||||||
|
|||||||
@@ -71,14 +71,14 @@ class Player(pygame.sprite.Sprite):
|
|||||||
self.gameSpeed = 1
|
self.gameSpeed = 1
|
||||||
self.updateCount = 0
|
self.updateCount = 0
|
||||||
|
|
||||||
self.collisionBoxes = []
|
self.collisionBoxes = pygame.sprite.Group()
|
||||||
|
|
||||||
collision = CollisionBox(0, 20, 60, 20, self.rect.center)
|
collision = CollisionBox(0, 20, 60, 20, self.rect.center)
|
||||||
self.collisionBoxes.append(collision)
|
self.collisionBoxes.add(collision)
|
||||||
collision = CollisionBox(-10, 5, 30, 20, self.rect.center)
|
collision = CollisionBox(-10, 5, 30, 20, self.rect.center)
|
||||||
self.collisionBoxes.append(collision)
|
self.collisionBoxes.add(collision)
|
||||||
collision = CollisionBox(0, 35, 25, 40, self.rect.center)
|
collision = CollisionBox(0, 35, 25, 40, self.rect.center)
|
||||||
self.collisionBoxes.append(collision)
|
self.collisionBoxes.add(collision)
|
||||||
|
|
||||||
|
|
||||||
def crouch(self):
|
def crouch(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user