Library for manage sprite sheet, and pallax background
Project description
This librairy contain so far 2 classes
ParallaxBackground :
This class allows you to automate the parallax effect. It is possible to stack background images and classify displays on the screen allowing continuous scrolling to the right or left. Each layer scrolls at an increasing speed the closer you get to the top of the stack.
Example:
win = pygame.display.set_mode((800, 447))
background = ParallaxBackground()
background.add_background(Path("bg0.png"))
background.add_background(Path("bg1.png"))
background.add_background(Path("bg2.png"))
#by default speed is 5, but you can
# ex: background.speed = 4
while(run):
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
# -1 for left scrolling or 1 for right scrolling
if keys[pygame.K_LEFT]:
background.update(-1)
elif keys[pygame.K_RIGHT]:
background.update(1)
else:
background.update(0)
background.draw(win)
pygame.display.update()`
SpriteSheet :
This class simplifies the use of sprite sheets to produce animations. For a sprite sheet it is possible to extract an image at a position by its column, row. The class also allows you to extract images from the sprite sheet dna an iterable list
Example:
win = pygame.display.set_mode((800, 447))
#for a sprite sheet of images 90px X 90px on 2 rows and 5 columns
sprites = SpriteSheet(Path("chess_set.png"), 90, 90, 2, 5)
while(run):
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
x = 0
sprite:Surface
for sprite in sprites.get_sprite_list():
win.blit(sprite, (x,0))
x += sprite.get_width()
pygame.display.update()
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
Built Distribution
File details
Details for the file PygameToolsBox-1.0.3.tar.gz
.
File metadata
- Download URL: PygameToolsBox-1.0.3.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0363ceb66cd3af2da90a5664335a9204b9c9d4f8ab9c711db34834981563812e |
|
MD5 | f7c31b8928ff6e7fe0cdfc435e9a15de |
|
BLAKE2b-256 | 88499c07d664bf5f011589490e3933b3d848d19e37388c69fec4b59557973367 |
File details
Details for the file PygameToolsBox-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: PygameToolsBox-1.0.3-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96c2ecaa54caaa3faac21a83ca03556ae8fc10eed43f08bba6c13d6b73be1d0f |
|
MD5 | 443398647253f7bf1d4a8eb2ed2d65ba |
|
BLAKE2b-256 | 55c96cd7d2d2c72f780e86634dec1f35deca039178825f547375f37df2f7a0bf |