This lib allows you use your gif animation in pygame
if you have git installed, use:
git clone https://github.com/maxtaran2010/PygameAnimation.git
if you don't, download the zip file and unzip it.
enter the downloaded directory:
cd PygameAnimation
run this command in the project folder:
python3 -m pip install -r requirements.txt
You can see the example in example.py file
from pygameAnimations import Animation as Anim
import pygame
screen = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()
anim = Anim('<path>', screen, <scale>, delay=<delay-between-updates>)
while True:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
screen.fill((0, 0, 0))
anim.draw(<x>, <y>)
pygame.display.flip()
Replace <path> with your path to gif file, <scale> with your scale coeficient, <delay-between-updates> with your delay between updates of animation, <x> and <y> with position of drawing the gif on the screen
to pause animation, use:
anim.playing = Flaseto unpause:
anim.playing = Trueto set the frame, use:
anim.frame = <frame>replace <frame> with the frame you need
to set the static flip coeficient, use:
anim.flip = <x>, <y>replace <x> and <y> with flip coeficient by x and y
- When you stop animation, it automaticly returning to the first frame
- This is
BetaVersion! - Lib supports only
.gifand.pngformats.