https://github.com/kerodekroma/python-pygame-loader
Free loader asset to use it in your personal project
https://github.com/kerodekroma/python-pygame-loader
free-assets game-dev game-develop game-development pygame python
Last synced: 9 months ago
JSON representation
Free loader asset to use it in your personal project
- Host: GitHub
- URL: https://github.com/kerodekroma/python-pygame-loader
- Owner: kerodekroma
- License: mit
- Created: 2024-02-12T02:48:26.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-29T03:03:17.000Z (over 1 year ago)
- Last Synced: 2025-02-05T06:51:26.311Z (11 months ago)
- Topics: free-assets, game-dev, game-develop, game-development, pygame, python
- Language: Python
- Homepage: https://kerodekroma.itch.io/python-pygame-loader
- Size: 14.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python Pygame Loader
[](https://github.com/kerodekroma/python-pygame-loader/actions/workflows/build_pygame.yml/badge.svg)
This is the demo of the loader of python and pygame. LIVE DEMO LINK: https://kerodekroma.itch.io/python-pygame-loader
## Install Dependencies
```bash
pip install pygame pygbag
```
## Run the demo
Once you download this repo and their dependencies are available, run this command
```bash
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:
```py
from atlas_spritesheet import AtlasSpritesheet
```
Then you can just declare the proper class with the asset when your game starts
```py
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:
```py
loader_spritesheet.play(my_main_creen)
```