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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygame_animation_player-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 e3f63a53bef683ee0b893e439a3744dc30ba3bd633678f89f84d191db5295699
MD5 f5e7bbd2fa5607d6a0c3f23f0eeec850
BLAKE2b-256 899e061d1bc25e89c470df7526fb7804abb23d8eedf5597ee8087d3b3e997842

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pygame_animation_player-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fadaf41be7c7c24b519a73f8963c9c78095460ce1e1dfab501bb565848eca4d1
MD5 08dfb81a47cecb01dd44f0aded6e3567
BLAKE2b-256 3bf29e3adf7fb46446c02377b632cec18c8766bacee876b2e00033a984f1dfc1

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