Added monster behavior
This commit is contained in:
parent
693e4a49e8
commit
74e05b11d2
BIN
gamedata/assets/lemmings/monster/aura.png
Normal file
BIN
gamedata/assets/lemmings/monster/aura.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
@ -23,13 +23,13 @@ class Lemming(BaseObject):
|
|||||||
self.basespeed*=1.4
|
self.basespeed*=1.4
|
||||||
self.scoreratio*=5
|
self.scoreratio*=5
|
||||||
if skin=="monster":
|
if skin=="monster":
|
||||||
self.scoreratio*=3
|
self.scoreratio*=6
|
||||||
|
|
||||||
self.skin = skin
|
self.skin = skin
|
||||||
|
|
||||||
self.maxhealth = 2 # Pinmiks can be attacked by the monsters
|
self.maxhealth = 2 # Pinmiks can be attacked by the monsters
|
||||||
self.health = self.maxhealth
|
self.health = self.maxhealth
|
||||||
self.regen = 0.1
|
self.regen = 1
|
||||||
|
|
||||||
self.selected = False # If beeing redirected
|
self.selected = False # If beeing redirected
|
||||||
|
|
||||||
@ -77,9 +77,14 @@ class Lemming(BaseObject):
|
|||||||
for pinmik in self.game.gameloop.findname("Lemming"):
|
for pinmik in self.game.gameloop.findname("Lemming"):
|
||||||
if pinmik.skin!="monster":
|
if pinmik.skin!="monster":
|
||||||
if self.rect.collidepoint(pinmik.rect.center):
|
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):
|
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
|
# Spawning dust particles if being launched
|
||||||
if self.speed > self.basespeed*1.5:
|
if self.speed > self.basespeed*1.5:
|
||||||
@ -158,6 +163,9 @@ class Lemming(BaseObject):
|
|||||||
self.holdrect[1]+=int(vely)
|
self.holdrect[1]+=int(vely)
|
||||||
|
|
||||||
def draw(self):
|
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
|
# Shaking based on life
|
||||||
offx,offy = 0,0
|
offx,offy = 0,0
|
||||||
if self.health<self.maxhealth:
|
if self.health<self.maxhealth:
|
||||||
|
Loading…
Reference in New Issue
Block a user