pyscratch

The reference manual is intended to provide technical specifications for the functions in this library. If you are new to this library, visit getting-started.

Namespace

Everything in this library are directly under the pyscratch namespace. So for example, you can use pyscratch.game to refer to pyscratch.game_module.game or pyscratch.Sprite to refer to pyscratch.sprite.Sprite etc.

When you do import pyscratch as pysc, they become just pysc.game, pysc.Sprite and pysc.random_number etc.

Main Objects

You will be mainly interacting of these following types of objects:

1. pyscratch.game_module.game (pysc.game)

This is an object instead a type of objects. This object represents the game itself. You use it to start the game, to play sound, change backdrops and make global changes to the game. You can also use it to create events, but it is more convenient to create the events from the sprite.

2. pyscratch.sprite.Sprite

The Sprite objects are the objects that represents the sprites in the game.

3. pyscratch.event.Event & pyscratch.event.Condition

This is the object you will get when you run my_event = sprite1.when_game_start() The only way you will interact with this object is to add handler functions to it and to remove it.

4. Pygame objects that represents the assets

pygame is another library that this library depends on. You only need to interact with these objects when you are loading the assets (for the sprites, backdrops and text styles)

4.1. pygame.Surface

A pygame object that represents an image. All the images in this library are represented as pygame.Surface objects. You can use pyscratch.helper.load_image to load an image for you.

4.2. pygame.font.Font

A pygame object that represent the font (or the style of the text). Some functions require the font object to render the text. To create a font object:

font = pygame.font.SysFont(None, 48)  # None = default font, 48 = font size
 1"""
 2The reference manual is intended to provide technical specifications for the functions in this library. 
 3If you are new to this library, visit [getting-started](../getting-started/). 
 4# Namespace
 5Everything in this library are directly under the pyscratch namespace. 
 6So for example, you can use `pyscratch.game` to refer to `pyscratch.game_module.game` or `pyscratch.Sprite` to refer to `pyscratch.sprite.Sprite` etc. 
 7
 8When you do `import pyscratch as pysc`, they become just `pysc.game`, `pysc.Sprite` and `pysc.random_number` etc. 
 9
10
11# Main Objects
12You will be mainly interacting of these following types of objects: 
13## 1. pyscratch.game_module.game (pysc.game)
14This is an object instead a type of objects. This object represents the game itself. 
15You use it to start the game, to play sound, change backdrops and make global changes to the game. 
16You can also use it to create events, but it is more convenient to create the events from the sprite.
17
18## 2. pyscratch.sprite.Sprite 
19The Sprite objects are the objects that represents the sprites in the game.
20
21
22## 3. pyscratch.event.Event & pyscratch.event.Condition
23This is the object you will get when you run `my_event = sprite1.when_game_start()`
24The only way you will interact with this object is to add handler functions to it and to remove it. 
25
26
27## 4. Pygame objects that represents the assets
28pygame is another library that this library depends on. 
29You only need to interact with these objects when you are loading the assets (for the sprites, backdrops and text styles)
30
31### 4.1. pygame.Surface
32A pygame object that represents an image. 
33All the images in this library are represented as pygame.Surface objects. 
34You can use pyscratch.helper.load_image to load an image for you. 
35
36### 4.2. pygame.font.Font
37A pygame object that represent the font (or the style of the text). 
38Some functions require the font object to render the text.
39To create a font object: 
40```python
41font = pygame.font.SysFont(None, 48)  # None = default font, 48 = font size
42```
43"""
44
45from .event import *
46from .game_module import *
47from .helper import *
48from .sprite import *