Animated lemming
BIN
gamedata/assets/lemmings/Left/0.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
gamedata/assets/lemmings/Left/1.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
gamedata/assets/lemmings/Left/2.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
gamedata/assets/lemmings/Left/3.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
gamedata/assets/lemmings/Right/0.png
Normal file
After Width: | Height: | Size: 825 B |
BIN
gamedata/assets/lemmings/Right/1.png
Normal file
After Width: | Height: | Size: 831 B |
BIN
gamedata/assets/lemmings/Right/2.png
Normal file
After Width: | Height: | Size: 813 B |
BIN
gamedata/assets/lemmings/Right/3.png
Normal file
After Width: | Height: | Size: 859 B |
@ -20,6 +20,14 @@ class Lemming(BaseObject):
|
||||
self.restx = 0
|
||||
self.resty = 0
|
||||
|
||||
# Sprites
|
||||
self.orientations = ["Right","Left","Left","Right"]
|
||||
self.sprites = {}
|
||||
for i in self.orientations:
|
||||
self.sprites[i] = game.getSpriteDir("lemmings/"+i+"/")
|
||||
self.spriteindex = 0
|
||||
self.animspeed = 0.2
|
||||
|
||||
def step(self):
|
||||
|
||||
# Lean towards the normal speed
|
||||
@ -50,6 +58,9 @@ class Lemming(BaseObject):
|
||||
if distance<=self.radius:
|
||||
self.selected = True
|
||||
|
||||
# Animation
|
||||
self.spriteindex+=self.game.dt*self.animspeed*self.speed
|
||||
|
||||
def launch(self):
|
||||
# Launch itself in the mouse direction
|
||||
if len(self.cachedrel)>self.mincachedsize:
|
||||
@ -68,3 +79,8 @@ class Lemming(BaseObject):
|
||||
self.resty = vely-int(vely)
|
||||
self.rect[0]+=int(velx)
|
||||
self.rect[1]+=int(vely)
|
||||
|
||||
def draw(self):
|
||||
orientation = self.orientations[int(self.direction%360/361*4)]
|
||||
sprites = self.sprites[orientation]
|
||||
self.game.lib.drawcenter(self.game,sprites[int(self.spriteindex)%len(sprites)],self.rect.center[0],self.rect.center[1])
|
||||
|