-
Notifications
You must be signed in to change notification settings - Fork 37
2 Learning Character Animation Through SpriteSheet #33
Description
Issue: Bring Life to SwarmShot: Pet Animation Integration
Prerequisites
Before starting, ensure you have the following set up:
- Python: Install the latest version (Python 3.8 or above).
- Pygame: Install the latest version using:
pip install pygame
NOTE: Paths and File Organization:
All file paths should be relative to the root directory (SwarmShot folder).
Ex. Use 'Sprites/Sprites_Player/Char_003.png' for the character sprite path.
Replace \ with / in file paths, as Python treats \ as an escape sequence. For example:
Incorrect: Sprites\Sprites_Player\Char_003.png
Correct: Sprites/Sprites_Player/Char_003.pngHow to Run any File
We recommend running all files by keeping the root folder as the current directory (Swarmshot Folder ). Means , First Open the SwarmShot folder using V S Code . Using the left Explorer panel , Open the practice.py file in 📁Example_of_Game/Practice_Animation Folder . Run this practice.py file ( either by pressing run code button or typing following in the V S code terminal ).
python .\Example_of_Game\Practice_Animation\practice.pyYou can see a character animated through a sprite sheet . We can clearly see that both moving and Idle animations are correctly established. Explanation is in comments (written at the top ) in practice.py file.
Task Details
Create a python file with following naming in the 📁Practice_Animation Folder (which lies in 📁Example_of_Game )
- If you're from IIITA:
Roll_No_Name.py - If you're not from IIITA:
OpenSource_GithubUserName.py
Use practice.py as the base code and build upon it . (Copy code from practice.py file into your python file )
Replace the Player Character with Favorite pet
Replace the current player sprite (Char_003.png) with a pet sprite from the repository and implement:
- Movement animations for the chosen pet.
- Idle animations when the player isn't moving.
Steps:
- Navigate to the
Sprites/Sprites_Pet/folder in the repository. Select a pet sprite:PET_BlueBird.pngPET_Fox.pngPET_Racoon.png
- Update the
Playerclass to load your chosen pet sprite.
Example:self.sprite_sheet = pygame.image.load("Sprites/Sprites_Pet/PET_Fox.png").convert_alpha()
- Extract animation frames using the same logic as
Char_003.pnginpractice.py. - Implement proper movement and idle animations for the pet. ( Both animations are in the same pet spritesheet ! )
Resources :
- Video Guide for Spritesheet Parsing
- Just use this as reference , code structure might vary , but concept is same .
Submission Guidelines
- Create a new Python file in this format:
- If you're from IIITA:
Roll_No_Name.py - If you're not from IIITA:
OpenSource_GithubUserName.py
- If you're from IIITA:
- PR description shall be :
Issue: #33 Added my favourite pet .




