Overflown/gamedata/objects/transition.py

42 lines
1.2 KiB
Python
Raw Normal View History

2021-11-23 11:24:59 +01:00
from gamedata.objects.base import BaseObject
class Transition(BaseObject):
2021-11-23 18:53:48 +01:00
def __init__(self,game,time=0.7,holdtime=0,level=None):
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
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-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):
if self.level:
2021-11-25 13:41:38 +01:00
self.game.scenes.ingame(self.game,level = self.level)
2021-11-23 18:53:48 +01:00
else:
self.game.scenes.overworld(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])