Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finding how to create properly a scene (without shenanigans) #8

Open
naulan-chrzaszcz opened this issue Dec 17, 2022 · 0 comments
Open
Labels
help wanted Extra attention is needed

Comments

@naulan-chrzaszcz
Copy link
Member

naulan-chrzaszcz commented Dec 17, 2022

Old code

class Scene0(object):
    """ Scene n°0
            Qu'es-ce qu'il se passe ?
                1. Debut = Fade in sur "intro-bg.png" pendant 1.5s
                2. Reste static pendant Stage1Msc
                3. Fade out sur "intro-bg.png" pendant 1.5s
                4. Fin = Passe à la Scene n°1
    """

    def __init__(self):
        self.step = [True, False]
        self.finish = False
        self.background = pg.image.load("res/sheets/intro-bg.png")
        self.alpha = 0
        self.t = 0

    def getFinish(self) -> bool:
        return self.finish

    def start(self, surface: Surface, dt: float) -> None:
        """ Demarre l'animation.
            (Fade in par default)
                :param dt: DeltaTime """
        surface.fill((0, 0, 0))

        # Timer
        if int(self.t) == 100:
            # Disable fade in and enable fade out
            self.step = [False, True]
        elif int(self.t) == 200:
            # Pass to scene n°1
            self.finish = True

        self.background.set_alpha(self.alpha)
        self.alpha += (5 * dt) if self.step[0] else 0
        self.alpha -= (5 * dt) if self.step[1] else 0
        surface.blit(self.background, (0, 0))
        self.t += (1*dt)
@naulan-chrzaszcz naulan-chrzaszcz added the help wanted Extra attention is needed label Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant