Added monster behavior

This commit is contained in:
theo@manjaro 2021-09-19 15:49:34 +02:00
parent 693e4a49e8
commit 74e05b11d2
2 changed files with 12 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -23,13 +23,13 @@ class Lemming(BaseObject):
self.basespeed*=1.4
self.scoreratio*=5
if skin=="monster":
self.scoreratio*=3
self.scoreratio*=6
self.skin = skin
self.maxhealth = 2 # Pinmiks can be attacked by the monsters
self.health = self.maxhealth
self.regen = 0.1
self.regen = 1
self.selected = False # If beeing redirected
@ -77,9 +77,14 @@ class Lemming(BaseObject):
for pinmik in self.game.gameloop.findname("Lemming"):
if pinmik.skin!="monster":
if self.rect.collidepoint(pinmik.rect.center):
pinmik.health-=self.game.dt
pinmik.health-=self.game.dt*3.5
if self.holdrect.collidepoint(pinmik.rect.center):
pinmik.health-=self.game.dt
pinmik.health-=self.game.dt*2
# Lean towards middle
angle_to_mid = math.degrees(math.atan2(self.game.DISPLAY_HEIGHT/2-self.rect.center[1],self.game.DISPLAY_WIDTH/2-self.rect.center[0]))
if abs(angle_to_mid-self.direction-360)<abs(angle_to_mid-self.direction):
angle_to_mid-=360
self.direction += (angle_to_mid-self.direction)*self.game.dt*0.5
# Spawning dust particles if being launched
if self.speed > self.basespeed*1.5:
@ -158,6 +163,9 @@ class Lemming(BaseObject):
self.holdrect[1]+=int(vely)
def draw(self):
if self.skin=="monster":
# Red aura
self.game.lib.drawcenter(self.game,self.game.sprite_lib["lemmings/monster/aura.png"],self.rect.center[0],self.rect.center[1])
# Shaking based on life
offx,offy = 0,0
if self.health<self.maxhealth: