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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygame_animation_player-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 1fdc2c7acdf7e2f8e66ec4f685fad25776805518cf6eb3a30203d91b86fb8a0a
MD5 45f887aca7ed6c97be9b8ad590126bfe
BLAKE2b-256 f311ccc0cf60f760e90fab4248e2679b2afc154b9d6303c892cd9eb73543867b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pygame_animation_player-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 823f20423c55233e926241cedc3a5dab4129ad0de7e41bdff8ad435319b1f7b7
MD5 77cdd943991cfc23e55d6970f27f9f51
BLAKE2b-256 64d11ade5f2f5ccf5210c9fab9512a0bcb9286c9d9bf67ac644b7ab86ec4f724

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