Overflown/gamedata/objects/transition.py
2021-11-25 13:41:38 +01:00

42 lines
1.2 KiB
Python

from gamedata.objects.base import BaseObject
class Transition(BaseObject):
def __init__(self,game,time=0.7,holdtime=0,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.holdtimer = game.lib.Timer(holdtime)
self.hold = False
self.alpha = 0
self.ispaused = False
self.depth = 4
def step(self):
if not self.hold:
self.alpha = (1-self.timer.getratio())*255
if self.timer.tick(self.game.dt):
self.hold = True
self.alpha = 255
else:
if self.holdtimer.tick(self.game.dt):
if self.level:
self.game.scenes.ingame(self.game,level = self.level)
else:
self.game.scenes.overworld(self.game)
self.game.globals["pause"] = False
def draw(self):
self.surface.set_alpha(self.alpha)
self.game.window.blit(self.surface,[0,0])