PinmikPanik/gamedata/objects/info.py

38 lines
1.1 KiB
Python

from gamedata.objects.base import BaseObject
class Info(BaseObject):
def __init__(self,game,message,color=[255]*3,temps=1):
super().__init__(0,0,game,game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT)
self.timer = game.lib.Timer(temps)
self.depth = 999
self.txtSurface = game.fontfilebig.render(message,False,color)
self.blackSurface = game.pygame.Surface((game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT))
self.blackSurface.fill([0]*3)
self.blackSurface.set_alpha(100)
def step(self):
game = self.game
self.timer.tick(game.dt)
if self.timer.getloops()>1:
game.gameloop.delid(self.id)
def draw(self):
game = self.game
self.txtSurface.set_alpha(255)
self.blackSurface.set_alpha(255)
if self.timer.getloops()==1:
alpha = min(1,self.timer.getratio())
self.txtSurface.set_alpha(alpha*100)
self.blackSurface.set_alpha(alpha*255)
game.window.blit(self.blackSurface,[0,0])
game.lib.drawcenter(game,self.txtSurface,game.DISPLAY_WIDTH/2,game.DISPLAY_HEIGHT/2)