Installation
This section shows you how to install PyScratch on your computer.
In-Page Navigation
Installation
1. Install Python and VSCode
2. Open a new folder for your game on VSCode
Name the new folder, let say, my_first_game
3. Install PyScratch
On the terminal, run this to install PyScratch:
pip install pyscratch-pysc
Note that this library is
pyscratch-pyscon pip.pyscratchon pip is another Python library that has no association with this library.
If you are installing on Windows
Continue with this guide and try to start the game with an empty scene.
If you get aModuleNotFoundError: No module named 'pyscratch' when you run the empty scene, your vscode might be using another Python installation that is different to the one that the default pip uses.
In this case, you should use the following line but substitute /path/to/python.exe with the path of the Python installation that your vscode uses.
/path/to/python.exe -m pip install pyscratch-pysc
You can find the path from the terminal before the path of your script when you click the Run button on vscode.
username@pc-name:/working/dir$ /path/to/python.exe /path/to/script/main.py
Traceback (most recent call last):
...
4. You are good to go!
Start the game with an empty scene
Create a new file in the project folder called main.py. This script is where you start the game.
Put in these lines below and run the script main.py.
import pyscratch as pysc
WIN_WIDTH = 500 # change me
WIN_HEIGHT = 500 # change me
FRAMERATE = 60
# set screen size
pysc.game.update_screen_mode((WIN_WIDTH, WIN_HEIGHT))
# start the game with a the framerate
pysc.game.start(FRAMERATE)
You should see a pygame window open. The program finishes when you close the window. You can also exit the program by pressing the escape key (Esc).
You can adjust the window size by changing the value of WIN_WIDTH and WIN_HEIGHT.
This is how the folder should look like
├─ my_first_game/
├─ main.py