Pensiero Computazionale Informazioni Pratiche
Pensiero Computazionale Informazioni Pratiche
Pensiero Computazionale Informazioni Pratiche
Pensiero computazionale
Informazioni pratiche
Alberto Montresor
Lezione 2: Introduzione a Scratch
Università di Trento
2017/03/14
Palcoscenico / stage
Copione / script
Attori / sprite
Stage
The Sprite List displays names and thumbnails for all the sprit
project. New projects begin with a white
Lista degli sprite / stageStage and a single cat-
sprite, as illustrated in Figure 1-5.
Thumbnail for
Choose a sprite from library.
the Stage
Paint new sprite.
The buttons above the Sprite List let you add new sprites to
from one of four places: Scratch’s sprite library , the built-in
the sprite’s name, its current (x,y) position and direction, its rotation
and visibility state, and whether it can be dragged in Presentation mo
Informazione sullo sprite
Let’s briefly talk about each of these options.
Figure
1. Nome1-12:dello
Sprite sprite
info area(modificato)
2. Coordinate correnti
The edit box at the top of this area allows you to change the sp
3. Direzione
name.
4. StileYou’ll use this box many times in this book.
di rotazione
The x and y values show the sprite’s current
5. Può essere spostato nella versione a tutto schermo position on the Sta
Drag the sprite onto the Stage and watch what happens to these numb
6. Nascosto / mostrato
The sprite’s direction indicates which direction the sprite will m
in response to a movement block. Drag the blue line emanating from
Gestione dei costumi
Undo / Redo
Area di disegno
Strumenti di
disegno
Zoom
Dimensione tratto
Bitmap
Vettoriale
Now that you’ve seen the essentials of the Scratch toolbar, we’ll ta
Dettagli
briefly about Scratch’s sull’editor
built-in dello sprite
Paint Editor.
You can use the Paint Editor (Figure 1-15) to create or edit
This is what we see costumes
when a
backdrops. (Of course, you’re free to use your favorite we paint theimage-editing
white part with p
the transparent color.
gram, too.) If you want to learn more about Scratch’s Paint Editor, che
area, as shown in Figure 1-16. The center point is determined This by the
grid inter-
is the backdrop of
out ScratchPaintEditor.pdf
section (located
of these two axes, so to shift in the
a costume’s online
center, resources,
just drag them to a which can b
the Stage.
downloaded
new position. Tofrom http://nostarch.com/learnscratch/).
hide the axes, click the same button again.
Figure 1-17: You can make any part of an image transparent by filling it with the “trans-
parent” color.
The center of rotation is
determined by the intersection
Now that you know your way around the Scratch interface, we’ll put
of these two axes. You can
change the center of rotation
that knowledge to good use and make something fun. Roll up your sleeves
by dragging these axes or by
clicking the mouse on the
and get ready: We’re making a game!
desired center point. Set costume
center
Editor di suoni
Lista
suoni
1. Libreria sprite
2. Disegna sprite 1. Libreria suoni
3. Carica sprite 2. Registra suono
4. Webcam 3. Carica suono
List displays names and thumbnails
Try itfor
outall the sprites in your
w projects begin with a white Stage and a single cat-costumed
ustrated in Figure 1-5.
• Provate:
• Aggiungete nuovi sprite
Choose a sprite from library.
• Dalla libreria
Paint new sprite.
• Disegnatene uno
• Caricando un file scaricato dalla rete
• Con la webcam Get new sprite from camera.
• Upload
Cambiate l’ordine degli sprite from file.
sprite
• Potete trascinarli a Thumbnail
vostro piacimento
for Sprite1
• Provate a premere Click
il tasto
the button to display
sprite information.
• Cambiate il nome allo sprite
Use these buttons to create a
• Modificate lo stile dinew
rotazione
backdrop.
• Mostrate/nascondete lo sprite
• Movimento assoluto:
• vai a x [],y []
• vai dove x è []
• vai dove y è []
• scivola in [] secondi a x [], y []
• raggiungi puntatore del mouse
• Movimento relativo:
• fai [] passi
• cambia x di []
• cambia y di []
Coordinate dello sfondo
the second “move” command sent it right. The motion depends on (or is
relative to) the sprite’s current direction. The direction convention used in
Scratch is illustrated in Figure 2-5.Movimento
0 (360)
180 (–180)
Figure 2-5: In Scratch, 0 is up, 90 is right, 180 is down, and –90 is left.
• Assoluto
You
• can turn
punta a sprite toward
in direzione [] a particular direction (or heading) with the
point• inpunta versocommand.
direction
To choose up, right, down, or left, just click
the down arrow and
puntatore delselect
mouseone of these options from the drop-down menu.
For other directions, type the value you want in the white edit box. You can
• Relativo
even use negative values! (For example, typing 45 or –315 will both point
the sprite
• northeast.)
routa di [] gradi
You’ll find the sprite’s current direction in the sprite info area. You can also click the
checkbox next to the direction block (in the Motion palette) to see the direction on
Stage, you can use the x position and y position reporter blocks. Click the
Dettagli
checkboxes next to these blocks tosul
see movimento
their values on the Stage.
Motion commands work with reference to a sprite’s center, which you can set in the Paint
Editor. For example, sending a sprite to point (100,100) moves the sprite so that its center
is at (100,100), as illustrated in Figure 2-3. Therefore, when you draw or import a cos-
tume for a sprite you plan to move around, pay special attention to its center!
Sprite’s
center 100
Mouse2 sprite
100 200
Mouse1 sprite
TRY IT OU T 2-1
Aspetto, suoni
• Assoluto vs relativo
• “porta”: assoluto
• “cambia”: relativo
Alcuni dettagli sull’aspetto
clear
color effect
fisheye effect
whirl effect
pixelate effect
mosaic effect
ghost effect
brightness effect
Figure 3-4: This figure shows what happens to the cat when you apply Scratch’s graphic
Penna
• Possibilità di modificare
• Colore [0-200]
• Luminosità [0-100]
• Dimensione [0-255]
Sensori
• Tastiera
• Mouse
• Rapporti fra sprite (distanza/tocco)
perform these operations, called operators, are shown in Figure 1-27. Sin
these blocks produce a number, you
Operatorican use them as inputs to any bloc
that accepts numbers, as demonstrated in this figure.
Example
Operator
• Gli1-27:
Figure operatori possono
Arithmetic essere
operators annidati:
in Scratch
{0, 1}
{–2, –1, 0, 1, 2}
The outputs of pick random 0 to 1 and pick random 0 to 1.0 are different. The
first case will give you either a 1 or a 0, but the second gives a decimal value between
0 and 1. If any input to the pick random block contains a decimal point, the output
will also be a decimal value.
Sequenza
Cicli (+eventi, +parallelismo)
Try it out!
nsider the following script and its output. Re-create the script, add
Create
•script
eng7. and its
necessary pen
lecommands,
seguenti
output. thefigure
Re-create run script,
it, andaddgeometriche
explain how it
utilizzando la penna
works.
Create the script shown below, add the necessary pen commands,
tup commands, run it, and explain how it works.
run it. Explain how the script works. 8. Write a program that produces the output s
ng script
eate theand its output.
script shown Re-create
below, the
addscript, add
the necessary pen commands, and
n8. Write a the
program that produces the output shown below.
mmands, run it, and explain how it works.
it. Explain how script works.