Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

kerodekroma/python-pygame-loader

Repository files navigation

Python Pygame Loader

CI

This is the demo of the loader of python and pygame. LIVE DEMO LINK: https://kerodekroma.itch.io/python-pygame-loader

Install Dependencies

pip install pygame pygbag

Run the demo

Once you download this repo and their dependencies are available, run this command

python main.py

Usage

These steps are part of a single intro of how to add in your code, you can find further details in the main.py file:

from atlas_spritesheet import AtlasSpritesheet

Then you can just declare the proper class with the asset when your game starts

 file_path = 'assets/python-pygame-loader/python-pygame-loader'
 '''
 this constructor method needs 3 params:
 - the .png file where is located the spritesheet of the animation
 - the .json file where is located the metadata of the spritesheet
 - the scale of the sprite, you can reduce/enlarge the sprite
 '''
 loader_spritesheet = AtlasSpritesheet(f'{file_path}.png', f'{file_path}.json', 4)
 '''
 the `setup` method needs 3 params:
 - the coords to show the animation
 - the frame rate of it, or how many FPS must run the animation itself
 - If the animation must be repeated or not
 '''
 self.loader_spritesheet.setup((0, 0), 20, True)

Finally, you can play the animation it into the game loop:

 loader_spritesheet.play(my_main_creen)

About

Free loader asset to use it in your personal project

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /