From: 711215 <711215@pdsb.net> Date: Sun, 10 Jul 2022 16:29:28 +0000 (-0400) Subject: fade in/out classes X-Git-Url: http://git.skullheadx.com/nixos/blog/openbsd_html_css.html?a=commitdiff_plain;h=cfd4187938d895acac0ce24effde1eb213a7c893;p=Pygame-Jam.git fade in/out classes just uh initialize and update in a loop --- 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