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.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.0.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.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygame_animation_player-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 46f07563de3f8b6fe1af0faa0c50d0016bc5d0829e94ab1e2e379aaa2fbf1acf
MD5 113a9a1161a1134308a009213e39512b
BLAKE2b-256 f0558ff41442b7d2e020dd9a59542482fc4c8c1122da30bb7acf1fe34bf59399

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pygame_animation_player-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f91be16437514512a4ae3a12c5d8a1f5e88b8579a76baea01066f3b652304831
MD5 4d5f48a4b49fbe8d7e1f6c646138c18c
BLAKE2b-256 da4efdf59d9bc76329a7458e424708d3007e122f5cc745651f8f7aa38a3b25f4

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