(Redirected from C)
A C block is a block that is shaped like the letter "C" so other blocks can fit inside it. These blocks perform the conditions and loops.
Shape
C blocks have a "mouth" (it looks like the letter "C", hence the name) — the blocks that will be placed inside the C block go in these mouths. All but one of the C blocks consist of one mouth — the other, if <> then, else, consists of two mouths. (For this reason, this block is occasionally referred to as an "E block".[1][2]) When any of the other C blocks are dragged over a stack of blocks — if the C is empty — its mouth extends to wrap around them.
repeat (10) repeat until <(loudness) > [30]> glide (1) secs to x: (10) y: (0) wait (1) secs go to x: (0) y: (0) end play sound (meow v) until done end
In Scratch 1.2 and earlier, C-block scripts could only be built one block at a time.
Most C blocks, like Stack Blocks, have a notch on the top of the block and a bump on the bottom, signifying that other blocks can be stacked above or below them. The forever
block is an exception in that it only has a notch, as if blocks could be placed under it, they would never run.
C Blocks in Scratch 3.0
In Scratch 3.0, there are five C blocks, and they can all be found in the Control category.
Note: | Click on a block for more information. |
repeat ()
forever
— this block is also a Cap Block.if <> then
if <> then else
repeat until <>
Removed C Blocks
This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective. |
forever if <> { } :: control cap
In Scratch 1.4 and earlier, the forever if <>::control
block could be used. This can be recreated with this workaround:
forever if <> then end end
Uses
As C blocks are for checks and loops, they are used in many places. Some uses include:
- Creating a scripts which runs forever
when gf clicked forever turn cw (15) degrees
- Checking a condition
when [space v] key pressed if <(loudness) > [30]> then stop [all v] end
- Repeating an animation a certain amount of times
when gf clicked repeat (200) turn ccw (36) degrees change [color v] effect by (1) end
Here is an example for both checks and looping:
when I receive [Decrease health v] change [Health v] by (-1) if <(health) = [0]> then repeat (8) change [color v] effect by (25) end end
There is a check (the If () Then block is checking if the variable Health has a value of 0), and inside the check is a repeat loop (with the Repeat () block). Note how C blocks can be placed inside other C blocks.