From cfd4187938d895acac0ce24effde1eb213a7c893 Mon Sep 17 00:00:00 2001 From: 711215 <711215@pdsb.net> Date: Sun, 10 Jul 2022 12:29:28 -0400 Subject: [PATCH] fade in/out classes just uh initialize and update in a loop --- Function/Fade.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Function/Fade.py diff --git a/Function/Fade.py b/Function/Fade.py new file mode 100644 index 0000000..9b556bc --- /dev/null +++ b/Function/Fade.py @@ -0,0 +1,34 @@ +from Setup import * + +class fadein: + def __init__(self): + self.transparency = 255 + self.overlay = pg.Surface((1080, 640)) + self.overlay.fill((0, 0, 0)) + self.overlay.set_alpha(self.transparency) + + def update(self): + if self.transparency > 0: + self.transparency -= 1 + self.overlay.set_alpha(self.transparency) + self.draw() + + def draw(self): + screen.blit(self.overlay, (0, 0)) + + +class fadeout(): + def __init__(self): + self.transparency = 0 + self.overlay = pg.Surface((1080, 640)) + self.overlay.fill((0, 0, 0)) + self.overlay.set_alpha(self.transparency) + + def update(self): + if self.transparency < 255: + self.transparency += 1 + self.overlay.set_alpha(self.transparency) + self.draw() + + def draw(self): + screen.blit(self.overlay, (0, 0)) \ No newline at end of file -- 2.54.0