Grade 5Yin-yang programs from homework
As before, everyone did a really great job attacking the yin-yang challenge. As with last year, this turned up some interesting questions about using the fill command.
A creative variant from Chun (this is my slight recreation, she edited her own program during the class):
One of Jung's programs, with the other versions faded and tricky:
Classic from Tatia:
Interestingly, Pitchee used a different method to create the same picture. It is worth taking a look at her program in the editor so you can see the animation difference: Pitchee's YinYang.
In particular, this illustrates a method of building up more complicated pictures using simple elements that you already understand.
Inspired by Jung's name last week, I made my own version with a pair of dancing turtles:
Based on the questions from the homework, we wanted to do some investigation of different fill variations. These are versions we looked at:
- What happens if you have a program without a pen command, but you end a series of movements with fill red? The answer we found was that the fill doesn't do anything.
- Does it matter where, within a sequence of moves, you order your command pen path? Yes, it matters very much. Movements prior to that command will only position the turtle for the start of the fill.
- What if we use pen blue (or some other color) instead of pen path? This still creates a filled shape, but now we get an outline of our chosen pen color.
- What if we make a path that doesn't have a clear "inside" and "outside," what will get filled? We made an "N" shape and were all a bit surprised about what got filled. The key point is that the computer will still follow whatever algorithm it has for determining where to fill, but it may not do what you expect. The solution is to control the output by creating cases where you know what the computer will do.
More for loops
Finally, we worked through these:
- look at range program http://guide.pencilcode.net/edit/loops/range, also looked at see [5..1]
- replicate dandelion picture: http://guide.pencilcode.net/home/loops/dandelion
Finish the flower and replicate this star: http://jgplay.pencilcode.net/home/class/goldStar
Try to use loops for both!
For next time
We will continue working on loops, probably in next term.
- look at rectangle: http://guide.pencilcode.net/edit/loops/rectangle
- replicate rainbow: http://guide.pencilcode.net/home/loops/rainbow
Grade 6Laser attributes
Our focus today was on creating a new object with various attributes and then getting objects to interact.
In the first investigation, we simply created a new object and then changed the attributes to see what would happen: http://jgplay.pencilcode.net/edit/class/spriteTidbit
We had to do a deeper investigation of the function rgb() to make sure we understood what colors were getting produced. One of the ideas we discovered was that we could make our laser sprite larger so that it is easier to see the color changes, then change the size back once we are satisfied with the color choice.
As with for loops, the attribute investigation was a reminder of the key difference between code lines that are subsidiary to an earlier line (in the loop, a property of the object) and lines that are independent.
Building up our program, we added another element and a simple interaction. Now there is a wall and the laser shoots whenever we click the mouse, but then disappears when it hits the wall. Here is Titus's version:
The final homework is to add a target for the laser, something exciting when the target gets hit, and any other embellishments you like. For inspiration, here is my version, modified a bit during the class: