复习:第 5 课 5 分钟
- 箭头朝它指的方向画。
- 绕着图形走一整圈,就是转了 360 度。
- 所以每个角转 360 ÷ 边数,
polygon (sides) (size) :: custom能画出任何正多边形。
快问快答
八边形——一个有 8 条边的图形——箭头在每个角要转多少度?
看答案
45 度。360 ÷ 8 = 45。
今天的主题 3 分钟
- 星星就是箭头在每个角多转一点的图形
- 星星规则:转 180 − (180 ÷ 角数)
- 一个一边画一边变颜色的
star (points) (size) :: custom积木
学习目标
学完这一课,你会:
- 说出为什么转 144 而不是 72,五边形就变成了星星。
- 算出任何奇数个角的星星要转多少度。
- 做一个星星积木,并用它三次。
学一学:从图形到星星 28 分钟
1 · 一样的移动,更大的转向
这里有两个脚本。唯一的不同是转向。
repeat (5)
move (100) steps
turn cw (72) degrees
end
repeat (5)
move (160) steps
turn cw (144) degrees
end
怎么用: 点绿旗。先画五边形,再画星星。看 turn 框。
2 · 最尖的星星
转 180 就是掉头——箭头沿着来的路直直地回去。转差不多 180,它就以一个很尖的角度折回去,这样就画出一个很尖的角。所以最尖的星星要转:
turn cw ((180) - ((180) / (points))) degrees
| 角数 | 算式 | 转多少度 |
|---|---|---|
| 5 | 180 − 36 | 144 |
| 7 | 180 − 25.7 | 大约 154 |
| 9 | 180 − 20 | 160 |
怎么用: 点绿旗。会画出三颗星星:5 个角、7 个角和 9 个角。
3 · 星星积木
把它做成一个积木,就像多边形积木一样。这一个每画一条线就换一种颜色。
define star (points) (size)
repeat (points)
move (size) steps
turn cw ((180) - ((180) / (points))) degrees
change pen (color v) by (8)
wait (0.08) seconds
end
基础任务:一个积木画出三颗星星 24 分钟
打开你第 5 课的作品。留着画板和箭头。
第 1 步:星星积木
- 制作一个叫
star的积木,有两个输入:points和size。 - 照着学一学,搭好六个积木的定义。
第 2 步:大星星
- 在
when flag clicked下面放:erase all、set pen size to (3),再选一种画笔颜色。 pen up、go to x: (-75) y: (75)、point in direction (90)、pen down。star (9) (150) :: custom。
第 3 步:两颗小星星
- 走到 x: -215,y: -60,画
star (5) (70) :: custom。 - 走到 x: 145,y: -60,再画一颗。
- 给每颗星星一个自己的起始颜色。
when flag clicked
erase all
set pen size to (3)
set pen color to [#ff4fa3]
pen up
go to x: (-75) y: (75)
point in direction (90)
pen down
star (9) (150) :: custom
set pen color to [#ffd23f]
pen up
go to x: (-215) y: (-60)
point in direction (90)
pen down
star (5) (70) :: custom
set pen color to [#4fd1ff]
pen up
go to x: (145) y: (-60)
point in direction (90)
pen down
star (5) (70) :: custom
怎么用: 点绿旗。先是一颗 9 个角的大星星,然后是两颗 5 个角的小星星。
我的星星没有封口——它一直在绕圈。
检查括号。必须是 180 减去 (180 ÷ 角数)——把除法积木放在减法积木里面,不要反过来。
我的星星只有一种颜色。
change pen (color v) by (8) 必须在 define 帽子积木里的 repeat 里面。
有一条线把我的两颗星星连起来了。
在 go to x: (0) y: (0) 前面用 pen up,后面用 pen down。
满天星星
六颗星星,每次点绿旗都是不一样的星空。
- 每颗星星去一个随机的地方,大小也是随机的。
- 每颗星星有 5 个、7 个或 9 个角,随机选。
- 在舞台上显示最后一颗星星的角数。
怎么用: 点绿旗,再点一次就是新的星空。
Teacher reveal
repeat (6)
set [points v] to (((pick random (2) to (4)) * (2)) + (1))
pen up
go to x: (pick random (-210) to (120)) y: (pick random (-40) to (150))
point in direction (90)
pen down
star (points) (pick random (40) to (80)) :: custom
change pen (color v) by (17)
end
The sum makes 5, 7 or 9 and never an even number. Many pupils try pick random (5) to (9) and get broken stars at 6 and 8 — let them see it.
六个角
星星规则对 6 没用。换一种方法画一颗六角星。
- 用两个三角形,每条边都是 150。
- 第二个三角形是倒过来的,叠在第一个上面。
- 画好的星星有六个一样大的角。
怎么用: 点绿旗。先画蓝色的三角形,再画粉色的。
Teacher reveal
pen up
go to x: (-75) y: (43)
point in direction (90)
pen down
polygon (3) (150) :: custom
pen up
go to x: (75) y: (-44)
point in direction (-90)
pen down
polygon (3) (150) :: custom
The second triangle starts 150 to the right and 87 lower, facing left. Pupils often find the start point by trial and error, nudging x and y. That is fine — praise the ones who notice it is the corner of the first triangle’s mirror image.
跳跃规则
想象这些角是钟面上的一圈点。星星把每个点连到往前数几步的另一个点。这一步叫作跳(jump)。转向是:
turn cw (((360) * (jump)) / (points)) degrees
- 做一个积木
jump star (points) (jump) (size) :: custom。 - 画一颗跳 3 的 7 角星,再画一颗跳 3 的 8 角星。
- 在舞台上显示 points 和 jump。
怎么用: 点绿旗。先是一颗 7 角星,然后是一颗 8 角星。
Teacher reveal
define jump star (points) (jump) (size)
repeat (points)
move (size) steps
turn cw (((360) * (jump)) / (points)) degrees
wait (0.1) seconds
end
A jump of 1 is a polygon. A jump of 2 on 5 points is the classic star. If the jump and the points share a factor (8 and 2, 6 and 2) the line closes early — another nice thing for a fast pupil to discover.
点一下加一颗星星
把画板和今天学的混在一起。鼠标选地方,你的积木画星星。
- 点绿旗清空画板,并画一颗 7 角星。
- 每在舞台上点一下,就在你点的地方加一颗新星星。
- 每颗新星星有 5 个、7 个或 9 个角,大小随机,颜色也是新的。
- 原来的星星留在画板上。
怎么用: 点绿旗,然后在舞台上任意地方点一下,加一颗星星。
Teacher reveal
when stage clicked
pen up
go to x: (mouse x) y: (mouse y)
point in direction (90)
pen down
change pen (color v) by (pick random (10) to (40))
star (((pick random (2) to (4)) * (2)) + (1)) (pick random (40) to (90)) :: custom
pen up
Clicking a sprite does not count as clicking the Stage. If a pupil’s clicks “do nothing”, check they are not clicking on the arrow.
总结 5 分钟
- 星星就是箭头绕了不止一圈的图形。
- 最尖的星星转 180 − (180 ÷ 角数)。它只对奇数个角有用。
- 偶数个角需要两个图形,或者用跳跃规则。
- 循环里的颜色变化,让每条线都有自己的颜色。
- 星星
- 线会交叉的图形,所以每个角都是一个尖角。
- 掉头
- 转 180 度。箭头面向它来的方向。
- 跳(jump)
- 每条线沿着圆圈跳过几个点。
交作业
保存你的星星。下一课,你要把一个图形画了又画,每次转一点点——就得到一朵花。