Adding a Sprite

1. Create the Art for the Sprite

Adding a sprite to the game is very easy - just one line of code and it’s done. The hard part is to create the art to give life to your sprites. Follow this guide to learn how to do it.

2. Adding the Sprite to the Game

For a step-by-step guide, follow this tutorial

First, create a new file for the sprite.

player.py
import pyscratch as pysc

the_player = pysc.create_single_costume_sprite("assets/player-fish.png")

Second, import it in main.py

main.py
import pyscratch as pysc
import player # reference to the filename (player.py, not the variable name `the_player`)

# start the game
pysc.game.update_screen_mode((1280, 720))
pysc.game.start(60)

All the functions that create a sprite

Basic shapes

Single costume sprite

Animated sprite (multiple costumes and animations)

For a more custom sprite (advance)

Continue to learn more about creating a sprite.

Next


This site uses Just the Docs, a documentation theme for Jekyll.