Overflown/gamedata/objects/transition.py

31 lines
841 B
Python

from gamedata.objects.base import BaseObject
class Transition(BaseObject):
def __init__(self,game,time=0.7,level=None):
super().__init__(0,0,game)
self.color = [31,14,28]
self.surface = game.pygame.Surface((game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT))
self.surface.fill(self.color)
self.level = level
self.timer = game.lib.Timer(time)
self.alpha = 0
self.depth = 4
def step(self):
self.alpha = (1-self.timer.getratio())*255
if self.timer.tick(self.game.dt):
if self.level:
self.game.scenes.ingame(self.game,level = self.level)
else:
self.game.scenes.overworld(self.game)
def draw(self):
self.surface.set_alpha(self.alpha)
self.game.window.blit(self.surface,[0,0])