Skip to main content

A simple animation player for pygame sprites

Project description

Pygame Animation Player

A simple and animation player for pygame sprites that supports:

  • Multiple animation types (sprite sheets and individual frames)
  • One-shot and looping animations
  • Frame-rate independent timing
  • Easy integration with pygame sprites

Installation

pip install pygame-animation-player

Implementation

import pygame
from pygame_animation_player import Animation, AnimationPlayer

# Create animations
idle_anim = Animation(fps=0, frame1)
walk_anim = Animation(fps=12, *walk_frames)
attack_anim = Animation(fps=20, attack_spritesheet, tilesize=(16,16), one_shot=True)
# Add to your sprite
class Player(pygame.sprite.Sprite):
    def __init__(self):
        super().__init__()
        # self.image before AnimationPlayer.__init__()
        self.image = None
        self.animation_player = AnimationPlayer(
            self, 
            idle=idle_anim,
            walk=walk_anim,
            attack=attack_anim
        )
    
    def update(self, dt):
        self.animation_player.update(dt)

        if walking:
            self.animation_player.play("walk")
        else:
            self.animation_player.play("idle")

        if attack:
            self.animation_player.play("attack", 
                                        restart= True, 
                                        force_finish= True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygame_animation_player-1.0.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygame_animation_player-1.0.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file pygame_animation_player-1.0.2.tar.gz.

File metadata

  • Download URL: pygame_animation_player-1.0.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for pygame_animation_player-1.0.2.tar.gz
Algorithm Hash digest
SHA256 280a30109279411ecd7bb03e908c34a0dbae0430451fecce389890bf3234da4f
MD5 b5c87a9ededb2b90b9ecc8bd51a02ab9
BLAKE2b-256 91ec7058834ab1e26cc88cddc4a5067853ff66b243e675537020c020b00139fa

See more details on using hashes here.

File details

Details for the file pygame_animation_player-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pygame_animation_player-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9aaabe652880cc73c2192646ccbc8d450b54de15c577f2a4eed3089d12ace3c6
MD5 69c572193c6a3895fc44e457078c0368
BLAKE2b-256 2e545a05aa2c0c6bfc03f6aedd5a69d4d1ee110f2c6bb60b8fd6285b33d3933c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page