PinmikPanik/gamedata/objects/ingame/demo.py

35 lines
1.1 KiB
Python
Raw Normal View History

2021-09-17 15:00:19 +02:00
from gamedata.objects.base import BaseObject
import math
class Demo(BaseObject):
def __init__(self,game):
super().__init__(game.DISPLAY_WIDTH/2,game.DISPLAY_HEIGHT/2,game,0,0)
self.blinktimer = game.lib.Timer(0.5)
self.maxblink = 6
self.depth = 6
def step(self):
self.blinktimer.tick(self.game.dt)
if self.blinktimer.getloops()>=self.maxblink:
self.game.gameloop.delid(self.id)
def draw(self):
sprites = self.game.getSpriteDir("cursor/")
sprite = sprites[self.blinktimer.getloops()%2]
if self.blinktimer.getloops()>=self.maxblink-1:
sprite.set_alpha(self.blinktimer.getratio()*255)
elif self.blinktimer.getloops()==0:
sprite.set_alpha((1-self.blinktimer.getratio())*255)
else:
sprite.set_alpha(255)
if self.blinktimer.getloops()<self.maxblink:
2021-09-17 15:09:01 +02:00
for pinmik in self.game.gameloop.findname("Lemming"):
self.game.lib.drawcenter(self.game,sprite,pinmik.rect.center[0],pinmik.rect.center[1]+50)