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.

change tempo by (20)

set tempo to (60) bpm

(tempo)

change volume by (10)

set volume to (100) %

(volume)

change balance by (10)

set balance to (0)

(balance)

play frequency (440) Hz

stop frequency

Pen

clear

pen down

pen up

<pen down?>

set pen color to [#911a44]

change pen [hue V] by (10)

set pen [hue V] to (50)

(pen [hue V])

change pen size by (1)

set pen size to (1)

stamp

fill

write [Hello] size (12)

(pen trails)

paste on [ V]

cut from [ V]

Control

when green flag clicked

when [space V] key pressed

when I am [clicked V]

when <>

when I receive [ V] @addInput

broadcast [ V] @addInput

broadcast [ V] @addInput and wait

warp { }

wait (1) secs

wait until <>

forever { }

repeat (10) { }

repeat until <> { }

for ((i)) = (1) to (10) { }

if <> { } @addInput

if <> { } else { }

(if <> then [] else [])

report []

stop [all V]

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

when I start as a clone

create a clone of [myself V] :: control

(a new clone of [myself V])

delete this clone

pause all @pause

switch to scene [ V] @addInput

when [ V] is edited @addInput

define ((block)) [] (() @addInput)

delete block (() @addInput)

set [label V] of block (() @addInput) to []

([definition V] of block (() @addInput))

(this [script V])

Sensing

<touching [mouse-pointer V] ?>

<touching [#911a44] ?>

<color [#911a44] is touching [#911a44] ?>

ask [what’s your name?] and wait

(answer)

(mouse position)

(mouse x)

(mouse y)

<mouse down?>

<key [space V] pressed?>

([distance V] to [mouse-pointer V])

([hue V] at [mouse-pointer V])

([RGBA V] at [myself V])

reset timer

(timer)

(current [date V])

([costume # V] of [ V])

(my [neighbors V])

(object [myself V])

(url [snap.berkeley.edu])

(microphone [volume V])

(video [motion V] on [myself V])

set video transparency to (50)

<is [turbo mode V] on?>

set [video capture V] to <>

Operators

({} @addInput) (() @addInput) (<> @addInput)

(() + () @delInput @verticalEllipsis @addInput)

(() - ())

(() x () @delInput @verticalEllipsis @addInput)

(() / ())

(() ^ ())

(() mod ())

(() min () @delInput @verticalEllipsis @addInput)

(() max () @delInput @verticalEllipsis @addInput)

(round ())

([sqrt V] of (10))

(atan2 () / ())

(pick random (1) to (10))

<[] < [] @delInput @verticalEllipsis @addInput>

<[] = [] @delInput @verticalEllipsis @addInput>

<[] > [] @delInput @verticalEllipsis @addInput>

<<> and <> @delInput @verticalEllipsis @addInput>

<<> or <> @delInput @verticalEllipsis @addInput>

<not <>>

<<true (:: grey) :: operators> :: operators >

(join [hello ][world] @delInput @verticalEllipsis @addInput)

(split [hello world] by [ v])

(letter (1 v) of [world])

([length V] of text [hello world])

(unicode of [a])

(unicode (65) as letter)

<is [5] a [number V] ?>

<is [] identical to [] @delInput @verticalEllipsis @addInput ?>

(Javascript function \( [] @delInput @verticalEllipsis @addInput \) \{ [] \})

Variables

(variable)

set [ V] to [0]

change [ V] by [1]

show variable [ V]

hide variable [ V]

script variables ((a)) @addInput

inherit [ V]

Lists

(list [] @delInput @addInput)

(numbers from (1) to (10))

([] in front of @list)

(item [1 v] of @list)

(all but first of @list)

([length V] of @list)

(index of [thing] in @list)

<@list contains [things]>

<is @list empty?>

(map (() @addInput) over @list)

(keep items (<> @addInput) from @list)

(find first item (<> @addInput) in @list)

(combine @list using (() @addInput)

for each ((item)) in @list { }

add [thing] to @list

delete (1 v) of @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)