Follow that kite! ๐ช
When you write kite.center, VeeLang reads where the kite is right now. If the kite flies off, whatever you put there stays behind.
Put @ in front, and it follows the kite instead:
Canvas paper having width 400, length 300, fill "lightskyblue"
draw circle kite at 300, 60 having radius 15, fill "tomato"
draw line string from 60, 280 to @kite.center
forever {
move kite by -150, 30 in 2 seconds
move kite by 150, -30 in 2 seconds
}
Wherever the kite goes, the end of the string goes too. @ means "follow".
Follow a colour ๐จ
You can follow anything about a shape, not just where it is. This flower is always the same colour as the sun:
Canvas paper having width 400, length 250
draw circle sun at 80, 80 having radius 30, fill "gold"
draw circle flower at 300, 180 having radius 20, fill @sun.fill
forever {
sun.fill = "orange" in 2 seconds
sun.fill = "gold" in 2 seconds
}
Parts that follow ๐
Inside a shape's { }, a part can follow another part. The pupil stays in the eye, even when the eye moves:
Canvas paper having width 400, length 300
draw circle face at 200, 150 having radius 100, fill "peachpuff" {
circle eye at -35, -25 having radius 15, fill "white"
circle pupil at @eye.center having radius 6, fill "black"
}
forever {
move face.eye by 40, 0 in 1 second
move face.eye by -40, 0 in 1 second
}
Try it! ๐ฏ
- ๐ Give the kite a tail that follows it.
- ๐ Make a shadow under a bouncing ball:
draw oval shadow at @ball.x, 280.
Learn more in Making Things Move. Have fun! โจ