Wednesday, June 24, 2015

Class notes (grades 5 and 6 programming)

Fifth Grade

Ideas and questions from homework

  1. How do we make multiple turtles? This was actually the second exercise I planned for the day, so we reserved it for later in the session.
  2. What does dot() mean, compared with dot green, for example?
  3. Why were all three of the dots in our exercise different colors?
  4. How can we change the color of the background? For example, pink?

Background: make it big!
We started with the last question. I asked the group if they could come up with ways of doing this. The first idea was to try typing a command "background." In pencilcode, that doesn't work as this function isn't defined so they got an error message. I suggested that they already know commands they could use and then gave them more time. Shortly after that, each came up with a variation, using either dot or box to draw a very large shape of the right color.

Note: I have since noticed that background is a function in processing.JS, used in Khan Academy. I wonder if that was the source of this idea?

Dotty dots
We tackled questions 2 and 3 together. In a fairly quick discussion, the students explained to each other than dot <color> makes a dot of that color and "lightgray" is different from "gray." That left dot() a little bit unclear.

P and I explained that the parentheses told pencilcode that we had just entered a command (or function.) We had already seen another example of this with home(). Usually we would have to tell dot a color and a size. However, the system seems to have built-in defaults in case we call the command without giving extra parameters.

We explored a couple of other commands we know, fd and rt to see if they also had built in defaults and found that they do! fd()  is equivalent to fd 100 and rt() is the same as rt 90.

We also talked about which version is easier to understand and everyone was clear that it was easier to understand if we made the parameters explicit.

The Plum triangle redux
A fairly short discussion that the plum triangle was an artifact of the fact that we could only move by whole pixels, so any irrational distance can only be approximated. We all agreed that this was fine, but needs to be handled carefully in two cases:

  • If we suddenly make our drawings much larger, then the approximations may be visible and need adjustment
  • If we have a series of approximate moves, then the little errors might accumulate. One habit is to return the turtle to the origin using home() between drawing different elements of a complicated drawing.

Hatching new turtles
Falling in perfectly with my plans, the kids wanted a reminder about how to create new turtles. One student hadn't seen this before, but the others quickly remembered something like
e = hatch 'yellow'
e = rt 90
We corrected the second line to e.rt 90 and talked about the syntax (hatch creates a new turtle wearing the indicated color, e =  gives it a name, e. is how you tell the turtle e that there is a command for it to execute.
As a challenge, we got them to draw a square with the old turtle and a triangle with the new one.

The homework this week is for everyone to draw their names in Thai and English.
Last year, I had created 5 different programs that drew my name and/or animated it in different ways. Unfortunately, 2 of those seem to be broken, so I also have homework this week!

Sixth Grade

Trying to be logical
After the discussion last week, we saw that we would need to spend more time on while and logical conditions (if, and, or).  This time, I gave them sample code (you can play here):

I asked them to just focus on the gun turtle and to figure out what it does. Most of the action is in lines 22-24.
Ultimately, this led to a discussion of how many dots it would draw. We got 2 votes for 5 dots and 2 votes for 10. In the end, we created code to cover that part of the program and saw the turtle actually draws 6, so we needed to do some work to figure out why.

We stepped through the while loop and checked to see what was happening each stage.

Before moving on, we tried changing line 21 so that innerLoop would iterations from 1 to 100. Would that change turtle gun's output? Why or why not?

There was very limited progress on the projects this week. As a result, most of the homework assignments were the same, but with some extra guidance:

  • Titus and Win: look at this example program to see if you can figure out a way to get your game characters to follow the mouse, but to stay on a fixed horizontal line.
  • Boongie: look at this Thai flag program to see how to play sound files you find on the web
  • Gun: figure out a way to integrate bombs into your game

Here is Gun's progress so far:

No comments:

Post a Comment