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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygame_animation_player-1.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 16374027dfaa1b11f5ddde9fe11f1494c663718f8472f0492ce7572d05f190d4
MD5 ee1ef561dd258ffff45091c3536974ef
BLAKE2b-256 25f1d2149678914cdc94748412246bf0b236550ba81da695b327e52c94f7c536

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pygame_animation_player-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 26e98214b9c64365a7686a75f263434883808ed179ba9006fbeaaf2cd2b6fbe9
MD5 7354f5225eafb4eeb7922cf2595ee55e
BLAKE2b-256 2e2b57d07e0930c1dc2ea9d1f1a7eac4b3638eb349b5569f694f0572f529fe36

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