Snap! Blocks

Материал из Поле цифровой дидактики
Перечень всех блоков Snap! доступных в версии 8.0 - их можно использовать при описании процедур в вики, объединяя между собой

Blocks

Motion

move10steps: Moves the sprite along their direction.

turn15degrees: Turns the sprite clockwise.

turn15degrees: Turns the sprite counter-clockwise.

pointindirection90: Points the sprite towards a direction. 90 is right, 0 is up. Use "random" to point towards a random direction.

pointtowardsmouse-pointer: Points the sprite towards another sprite. The block can also be used to make a sprite face toward a mouse pointer or the center.

gotox:0y:0: Jumps the sprite to a position.

gotorandomposition: 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.

glide1secstox:0y:0: Smoothly (linearly) moves the sprite to a position.

changexby10: Moves the sprite horizontally. Positive to move right, positive to move left.

setxto0: Changes the sprite's horizontal position.

changeyby10: Moves the sprite vertically. Positive to move up, negative to move down.

setyto0: Changes the sprite's vertical position.

ifonedge,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.

xposition: Reports the current horizontal position.

yposition: Reports the current vertical position.

direction: Reports the sprite's direction.

Looks

switchtocostume: Changes the sprite's costume.

nextcostume: 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.

sayHello!for2secs: 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.

sayHello!: Shows a speech bubble without pausing the execution.

thinkHmm...for2secs: Like the say blocks, but shows a thought bubble for an amount of time. Conversely, it cannot be run on the stage.

thinkHmm...: Shows a thought bubble without pausing the execution.

widthofcostumecurrent: Reports a property of the costume.

stretchcurrentx:100y:50%: Stretches a costume.

newcostumewidthheight: Creates a costume from a list.

changeghosteffectby25: Intensifies or lessens an effect.

setghosteffectto0: Sets an effect intensity.

cleargraphiceffects: Resets all the effect amounts to 0.

ghosteffect: Reports the current amount of an effect.

changesizeby10: 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%.

setsizeto100%: 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.

gotofrontlayer: 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.

goback1layers: Send the sprite backwards by an amount of layers.

Sound

playsound: Plays a sound with its own sample rate.

playsounduntildone: Plays a sound and waits until the sound is done.

stopallsounds: Stops all the sounds that are currently being played.

playsoundat44100Hz: Plays a sound with a set sample rate.

durationofsound: Reports a property of a sound.

newsoundrate44100Hz: Creates a sound from the samples given.

restfor0.2beats: Delays execution for a varying amount of time based on the tempo.

playnote60for0.5beats: Plays a note.

setinstrumentto1: 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.

changetempoby20

settempoto60bpm

tempo

changevolumeby10

setvolumeto100%

volume

changebalanceby10

setbalanceto0

balance

playfrequency440Hz

stopfrequency

Pen

clear

pendown

penup

pendown?

setpencolorto

changepenhueby10

setpenhueto50

penhue

changepensizeby1

setpensizeto1

stamp

fill

writeHellosize12

pentrails

pasteon

cutfrom

Control

whenclicked

whenspacekeypressed

whenIamclicked

when

whenIreceive

broadcast

broadcastandwait

warp

wait1secs

waituntil

forever

repeat10

repeatuntil

fori=1to10

if

ifelse

ifthenelse

report

stopall

run

launch

call

pipe

tellto

askfor

whenIstartasaclone

createacloneofmyself

anewcloneofmyself

deletethisclone

pauseall

switchtoscene

whenisedited

defineblock

deleteblock

setlabelofblockto

definitionofblock

thisscript

Sensing

touchingmouse-pointer?

touching?

coloristouching?

askwhat’syourname?andwait

answer

mouseposition

mousex

mousey

mousedown?

keyspacepressed?

distancetomouse-pointer

hueatmouse-pointer

RGBAatmyself

resettimer

timer

currentdate

costume#of

myneighbors

objectmyself

urlsnap.berkeley.edu

microphonevolume

videomotiononmyself

setvideotransparencyto50

isturbomodeon?

setvideocaptureto

Operators

+

-

×

/

^

mod

min

max

round

sqrtof10

atan2÷

pickrandom1to10

<

=

>

and

or

not

true

joinhelloworld

splithelloworldby

letter1ofworld

lengthoftexthelloworld

unicodeofa

unicode65asletter

is5anumber?

isidenticalto?

Javascriptfunction(){}

Variables

variable

setto0

changeby1

showvariable

hidevariable

scriptvariablesa

inherit

Lists

list

numbersfrom1to10

infrontof

item1of

allbutfirstof

lengthof

indexofthingin

containsthings

isempty?

mapover

keepitemsfrom

findfirstitemin

combineusing

foreachitemin

addthingto

delete1of

insertthingat1of

replaceitem1ofwiththing

append

reshapeto43

combinations