Snap! Blocks
- Перечень всех блоков Snap! доступных в версии 8.0 - их можно использовать при описании процедур в вики, объединяя между собой
Blocks
Motion
move (10) steps: Moves the sprite along their direction.
turn cw (15) degrees: Turns the sprite clockwise.
turn ccw (15) degrees: Turns the sprite counter-clockwise.
point in direction (90 v): Points the sprite towards a direction. 90 is right, 0 is up. Use "random" to point towards a random direction.
point towards [mouse-pointer V]: Points the sprite towards another sprite. The block can also be used to make a sprite face toward a mouse pointer or the center.
go to x: (0) y: (0): Jumps the sprite to a position.
go to [random position V]: Jumps the sprite to another sprite, the mouse pointer, or the center. A two-input list can be also dropped into the slot for a select position.
glide (1) secs to x: (0) y: (0): Smoothly (linearly) moves the sprite to a position.
change x by (10): Moves the sprite horizontally. Positive to move right, positive to move left.
set x to (0): Changes the sprite's horizontal position.
change y by (10): Moves the sprite vertically. Positive to move up, negative to move down.
set y to (0): Changes the sprite's vertical position.
if on edge, bounce: Makes the sprite face away from the edge if it's in proximity, otherwise does nothing.
(position): Reports the sprite's current position as a two-item list.
(x position): Reports the current horizontal position.
(y position): Reports the current vertical position.
(direction): Reports the sprite's direction.
Looks
switch to costume [ V]: Changes the sprite's costume.
next costume: Cycles the sprite's costume to the next one. The turtle costume is never rolled over using this block.
(costume #): Reports the current costume number. 0 is the turtle costume, and other costumes start from 1 onwards.
say [Hello!] for (2) secs: Shows a speech bubble above a sprite for an amount of time. If run on the stage, a pop-up will appear on the top-left.
say [Hello!]: Shows a speech bubble without pausing the execution.
think [Hmm...] for (2) secs: Like the say blocks, but shows a thought bubble for an amount of time. Conversely, it cannot be run on the stage.
think [Hmm...]: Shows a thought bubble without pausing the execution.
([width V] of costume [current V]): Reports a property of the costume.
(stretch [current V] x: (100) y: (50) %): Stretches a costume.
(new costume @list width ( v) height ( v)): Creates a costume from a list.
change [ghost V] effect by (25): Intensifies or lessens an effect.
set [ghost V] effect to (0): Sets an effect intensity.
clear graphic effects: Resets all the effect amounts to 0.
([ghost V] effect): Reports the current amount of an effect.
change size by (10): Grows or shrinks the sprite. Note that it's not applied by a factor, 1.5 does not set the size to 150% from 100%, it sets it to 101.5%.
set size to (100) %: Sets the size of the sprite.
(size): Reports the current size.
show: Reveals the sprite if the sprite is currently hidden.
hide: Hides the sprite and ceases all touch sensing (other sprites cannot sense if they're touching hidden sprites, and "when I am clicked" events are disabled as well).
<shown?>: Reports true if the sprite is shown, false otherwise.
go to [front V] layer: Sends the sprite to either the front or back layer. Sending a sprite to front will also put it in front of UI elements, such as variable watchers, speech bubbles and ask dialogs.
go back (1) layers: Send the sprite backwards by an amount of layers.
Sound
play sound [ V]: Plays a sound with its own sample rate.
play sound [ V] until done: Plays a sound and waits until the sound is done.
stop all sounds: Stops all the sounds that are currently being played.
play sound [ V] at (44100 v) Hz: Plays a sound with a set sample rate.
([duration V] of sound [ V]): Reports a property of a sound.
(new sound @list rate (44100 v) Hz): Creates a sound from the samples given.
rest for (0.2) beats: Delays execution for a varying amount of time based on the tempo.
play note (60 v) for (0.5) beats: Plays a note.
set instrument to (1 v): Sets the instrument to be played into one of the four waveforms: (1) sine, (2) square, (3) sawtooth, (4) triangle. The triangle is not to be confused with a percussion instrument of the same name.
Pen
Control
broadcast [ V] @addInput and wait
run ({} @addInput) @verticalEllipsis @addInput
launch ({} @addInput) @verticalEllipsis @addInput
(call (() @addInput) @verticalEllipsis @addInput
(pipe [] @arrowRight (() @addInput) @delInput @verticalEllipsis @addInput)
tell [ V] to ({} @addInput) @verticalEllipsis @addInput
(ask [ V] for (() @addInput) @verticalEllipsis @addInput
create a clone of [myself V] :: control
switch to scene [ V] @addInput
define ((block)) [] (() @addInput)
set [label V] of block (() @addInput) to []
([definition V] of block (() @addInput))
Sensing
<touching [mouse-pointer V] ?>
<color [#911a44] is touching [#911a44] ?>
ask [what’s your name?] and wait
([distance V] to [mouse-pointer V])
([hue V] at [mouse-pointer V])
(video [motion V] on [myself V])
set video transparency to (50)
Operators
({} @addInput) (() @addInput) (<> @addInput)
(() + () @delInput @verticalEllipsis @addInput)
(() x () @delInput @verticalEllipsis @addInput)
(() min () @delInput @verticalEllipsis @addInput)
(() max () @delInput @verticalEllipsis @addInput)
<[] < [] @delInput @verticalEllipsis @addInput>
<[] = [] @delInput @verticalEllipsis @addInput>
<[] > [] @delInput @verticalEllipsis @addInput>
<<> and <> @delInput @verticalEllipsis @addInput>
<<> or <> @delInput @verticalEllipsis @addInput>
<<true (:: grey) :: operators> :: operators >
(join [hello ][world] @delInput @verticalEllipsis @addInput)
([length V] of text [hello world])
<is [] identical to [] @delInput @verticalEllipsis @addInput ?>
(Javascript function \( [] @delInput @verticalEllipsis @addInput \) \{ [] \})
Variables
script variables ((a)) @addInput
Lists
(map (() @addInput) over @list)
(keep items (<> @addInput) from @list)
(find first item (<> @addInput) in @list)
(combine @list using (() @addInput)
for each ((item)) in @list {
}
insert [thing] at (1 v) of @list
replace item (1 v) of @list with [thing]
(append @list @list @delInput @verticalEllipsis @addInput)
(reshape [] to (4) (3) @delInput @addInput)
(combinations @list @list @delInput @verticalEllipsis @addInput)
