Zeperox/gif-pygame

A Simple Question from a Begginer!

Opened this issue · 3 comments

How can i make a variable with this variable - example_gif = gif_pygame.load("giphy (1).gif") - so i couldn't make a lot of replicates in my code?

example_gif = gif_pygame.load("giphy (1).gif")

def animatedgif():
    while True:
        screen.fill((0, 0, 0))

        example_gif.render(screen, (500 - example_gif.get_width() * 0.5, 400 - example_gif.get_height() * 0.5))

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit();
                sys.exit()

            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    if example_gif.paused:
                        example_gif.unpause() 
                    else:
                        example_gif.pause() 

        pygame.display.update()

animatedgif(giphy.gif)

I want to put like a "animatedgif(myothergif), animatedgif(otherothergif)", etc.

Hi there!
Sorry for the wait.
I didn't quite understand what your question is about, may you please elaborate?

Hi there! Sorry for the wait. I didn't quite understand what your question is about, may you please elaborate?

Tnx for resposding me. I'm just trying to make variables with the function. In example bellow i want to replicate the function without have to create more functions:

If i want to display my (hypoteticous) gif2 so "animatedgif(gif2)"
If i want to display my (hypoteticous) gif3 so "animatedgif(gif3)"

Etc. Looks like a simple question but i'm trying to learn with the packages that i'm using in my game. Btw, you made a great work with GifPygame!

What I'd do is scrap the whole function and move its contents outside, and I would have a list of loaded gifs which I would cycle through by pressing a button.
Another solution would be exiting the function and calling it again with another gif as the parameter.
I hope this helps.

Etc. Looks like a simple question but i'm trying to learn with the packages that i'm using in my game. Btw, you made a great work with GifPygame!
Thanks! I hope the module helps you