File size: 8,542 Bytes
a522962
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
{
  "block_category": "Hat Blocks",
  "description": "Hat blocks are characterized by a rounded top and a bump at the bottom. They initiate scripts, meaning they are the starting point for a sequence of interconnected blocks.",
  "blocks": [
    {
      "block_name": "when green flag pressed",
      "block_type": "Events",
      "op_code": "event_whenflagclicked",
      "block_shape": "Hat Block",
      "functionality": "This Hat block initiates the script when the green flag is clicked, serving as the common starting point for most Scratch projects.",
      "inputs": null,
      "example_standalone": "when green flag clicked",
      "example_with_other_blocks": [
        {
          "script": "when green flag clicked\n  go to x: (0) y: (0)\n  say [Hello!] for (2) seconds\nend",
          "explanation": "This script makes the sprite go to the center of the stage and then say 'Hello!' for 2 seconds when the green flag is clicked."
        }
      ]
    },
    {
      "block_name": "when () key pressed",
      "block_type": "Events",
      "op_code": "event_whenkeypressed",
      "block_shape": "Hat Block",
      "functionality": "This Hat block initiates the script when a specified keyboard key is pressed.",
      "inputs": [
        {
          "name": "key",
          "type": "dropdown",
          "options": [
            "space",
            "up arrow",
            "down arrow",
            "right arrow",
            "left arrow",
            "any",
            "a",
            "b",
            "c",
            "d",
            "e",
            "f",
            "g",
            "h",
            "i",
            "j",
            "k",
            "l",
            "m",
            "n",
            "o",
            "p",
            "q",
            "r",
            "s",
            "t",
            "u",
            "v",
            "w",
            "x",
            "y",
            "z",
            "0",
            "1",
            "2",
            "3",
            "4",
            "5",
            "6",
            "7",
            "8",
            "9"
          ]
        }
      ],
      "example_standalone": "when [space v] key pressed",
      "example_with_other_blocks": [
        {
          "script": "when [space v] key pressed\n  repeat (10)\n    change y by (10)\n    wait (0.1) seconds\n    change y by (-10)\n  end",
          "explanation": "This script makes the sprite jump when the spacebar is pressed."
        },
        {
          "script": "when [right arrow v] key pressed\n  point in direction (90)\n  move (10) steps\nend",
          "explanation": "This script moves the sprite right when the right arrow key is pressed."
        }
      ]
    },
    {
      "block_name": "when this sprite clicked",
      "block_type": "Events",
      "op_code": "event_whenthisspriteclicked",
      "block_shape": "Hat Block",
      "functionality": "This Hat block starts the script when the sprite itself is clicked.",
      "inputs": null,
      "example_standalone": "when this sprite clicked",
      "example_with_other_blocks": [
        {
          "script": "when this sprite clicked\n  say [Ouch!] for (1) seconds\n  change [score v] by (-1)\nend",
          "explanation": "This script makes the sprite say 'Ouch!' and decreases the score by 1 when the sprite is clicked."
        }
      ]
    },
    {
      "block_name": "when backdrop switches to ()",
      "block_type": "Events",
      "op_code": "event_whenbackdropswitchesto",
      "block_shape": "Hat Block",
      "functionality": "This Hat block triggers the script when the stage backdrop changes to a specified backdrop.",
      "inputs": [
        {
          "name": "backdrop name",
          "type": "dropdown",
          "options": ["backdrop1", "backdrop2", "..."]
        }
      ],
      "example_standalone": "when backdrop switches to [game over v]",
      "example_with_other_blocks": [
        {
          "script": "when backdrop switches to [game over v]\n  stop [all v]\nend",
          "explanation": "This script stops all running processes when the backdrop changes to 'game over'."
        },
        {
          "script": "when backdrop switches to [level completed v]\n  stop [all v]\nend",
          "explanation": "This script stops all running processes when the backdrop changes to 'level completed'."
        }
      ]
    },
    {
      "block_name": "when () > ()",
      "block_type": "Events",
      "op_code": "event_whengreaterthan",
      "block_shape": "Hat Block",
      "functionality": "This Hat block starts the script when a certain value (e.g., loudness from a microphone, or the timer) exceeds a defined threshold.",
      "inputs": [
        {
          "name": "value type",
          "type": "dropdown",
          "options": [
            "loudness",
            "timer"
          ]
        },
        {
          "name": "threshold",
          "type": "number"
        }
      ],
      "example_standalone": "when [loudness v] > (70)",
      "example_with_other_blocks": [
        {
          "script": "when [loudness v] > (70)\n  start sound [scream v]\nend",
          "explanation": "This script starts a 'scream' sound when the microphone loudness exceeds 70."
        }
      ]
    },
    {
      "block_name": "when I receive ()",
      "block_type": "Events",
      "op_code": "event_whenbroadcastreceived",
      "block_shape": "Hat Block",
      "functionality": "This Hat block initiates the script upon the reception of a specific broadcast message. This mechanism facilitates indirect communication between sprites or the stage.",
      "inputs": [
        {
          "name": "message name",
          "type": "dropdown",
          "options": ["message1", "message2", "new message..."]
        }
      ],
      "example_standalone": "when I receive [start game v]",
      "example_with_other_blocks": [
        {
          "script": "when I receive [start game v]\n  show\n  go to x: (0) y: (0)\nend",
          "explanation": "This script makes the sprite visible and moves it to the center of the stage when it receives the 'start game' broadcast."
        },
        {
          "script": "when I receive [game over v]\n  set score to 0\n  stop [all v]\nend",
          "explanation": "This script stops all and resets the score on stage when it receives the 'game over' broadcast."
        }
      ]
    },
    {
      "block_name": "When I Start as a Clone",
      "block_type": "Control",
      "op_code": "control_start_as_clone",
      "block_shape": "Hat Block",
      "functionality": "This Hat block initiates the script when a clone of the sprite is created. It defines the behavior of individual clones.",
      "inputs": null,
      "example_standalone": "When I Start as a Clone",
      "example_with_other_blocks": [
        {
          "script": "when I start as a clone\n  go to x: (pick random -240 to 240) y: (pick random -180 to 180)\n  show\n  forever\n    move (10) steps\n    if on edge, bounce\n  end\nend",
          "explanation": "This script makes a newly created clone appear at a random position, become visible, and then continuously move 10 steps, bouncing if it hits an edge."
        }
      ]
    },
    {
      "block_name": "define [my custom block]",
      "block_type": "My Blocks",
      "op_code": "procedures_definition",
      "block_shape": "Hat Block",
      "functionality": "This Hat block serves as the definition header for a custom block's script. It allows users to define reusable sequences of code by specifying the block's name and any input parameters it will accept. This promotes modularity and abstraction in projects.",
      "inputs": [
        {
          "name": "PROCCONTAINER",
          "type": "block_prototype"
        }
      ],
      "example_standalone": "define jump (height)",
      "example_with_other_blocks": [
        {
          "script": "define jump (height)\n  change y by (height)\n  wait (0.5) seconds\n  change y by (0 - (height))\nend\n\nwhen green flag clicked\n  jump (50)\nend",
          "explanation": "This script first defines a custom block named 'jump' that takes a numerical input 'height'. The definition outlines the actions for jumping up and then down. Later, 'jump (50)' is called to make the sprite jump 50 units."
        }
      ]
    }
  ]
}