2021-11-23 11:24:59 +01:00
|
|
|
from gamedata.objects.base import BaseObject
|
|
|
|
|
|
|
|
class Transition(BaseObject):
|
|
|
|
|
2021-11-28 11:33:00 +01:00
|
|
|
def __init__(self,game,time=0.7,holdtime=0,level=None,endcinematic=False):
|
2021-11-23 11:24:59 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-11-28 11:33:00 +01:00
|
|
|
self.endcinematic = endcinematic
|
|
|
|
|
2021-11-23 11:24:59 +01:00
|
|
|
self.timer = game.lib.Timer(time)
|
2021-11-23 18:53:48 +01:00
|
|
|
self.holdtimer = game.lib.Timer(holdtime)
|
|
|
|
self.hold = False
|
2021-11-23 11:24:59 +01:00
|
|
|
self.alpha = 0
|
|
|
|
|
2021-11-25 13:41:38 +01:00
|
|
|
self.ispaused = False
|
|
|
|
|
2021-11-23 11:24:59 +01:00
|
|
|
self.depth = 4
|
|
|
|
|
|
|
|
def step(self):
|
2021-11-28 11:33:00 +01:00
|
|
|
|
2021-11-23 18:53:48 +01:00
|
|
|
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):
|
2021-11-28 11:33:00 +01:00
|
|
|
if not self.endcinematic:
|
|
|
|
if self.level:
|
|
|
|
self.game.globals["overworld"] = False
|
|
|
|
self.game.scenes.ingame(self.game,level = self.level)
|
|
|
|
else:
|
|
|
|
self.game.globals["overworld"] = True
|
|
|
|
self.game.scenes.overworld(self.game)
|
2021-11-23 18:53:48 +01:00
|
|
|
else:
|
2021-11-28 11:33:00 +01:00
|
|
|
self.game.scenes.end(self.game)
|
|
|
|
|
2021-11-25 13:41:38 +01:00
|
|
|
self.game.globals["pause"] = False
|
|
|
|
|
2021-11-23 11:24:59 +01:00
|
|
|
|
|
|
|
def draw(self):
|
|
|
|
self.surface.set_alpha(self.alpha)
|
|
|
|
self.game.window.blit(self.surface,[0,0])
|