No project description provided
It is not uncommon for games to have tens to hundreds of sprites. Loading each of these as an individual image would consume a lot of memory and processing power. To help manage sprites and avoid using so many images, many games use sprite sheets (also known as image sprites).
A sprite sheet consists of multiple sprites in one image. In other words, sprite sheets pack multiple sprites into a single picture. Using sprite sheet, video game developers create sprite sheet animation representing one or several animation sequences while only loading a single file:
Sprite Bounding Box
A frame (bounding box) can be used to delimit the sprite in the sprite sheet. This bounding box is defined with two 2D points
top_left and the
bottom_right, which their respective coordinates
y are relative to the top-left corner of the sprite sheet's image.
The mask of a sprite defines the 2D shape of the sprite. For example, the sprite sheet
metal_slug_sprite_standing_stance.png contains the 3 following sprites:
The masks of these sprites are respectively:
Aim of the project
- Detect sprites packed in an image (sheet) and draw their masks and bounding boxes into a new image with the same size of the original image.
- Present a 2D map of all the the sprites with their labels.
- Waypoint 1: Find the Most Common Color in an Image
- Waypoint 2: Write a Class Sprite
- Waypoint 3: Find Sprites in an Image
- Waypoint 4: Draw Sprite Label Bounding Boxes
- Waypoint 5: Write a Class SpriteSheet
- Python 3.7 is required.
- numpy (python support library)
- PIL.Image (python support library)
- Use git to clone the link to your local directory.
- Change the your current working directory to where you git the project.
- Open terminal and type
pipenv install -e Pipfileto install virtual environment.
- For example:
>>> from spriteutil import * >>> sprite_sheet = SpriteSheet('Barbarian.gif') >>> sprites, labels = sprite_sheet.find_sprites() >>> len(sprites) 39 >>> # Create the mask image with bounding boxes. >>> image = sprite_sheet.create_sprite_labels_image() >>> image.save('barbarian_bounding_boxes.png')
- If you have any problems using this library, please use the contact below.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size spriteutil_intek_2020_nqcuong96-1.0.0-py3-none-any.whl (7.8 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size spriteutil-intek-2020-nqcuong96-1.0.0.tar.gz (6.8 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for spriteutil_intek_2020_nqcuong96-1.0.0-py3-none-any.whl
Hashes for spriteutil-intek-2020-nqcuong96-1.0.0.tar.gz