## Tuesday, June 16, 2015

### Pac-Man is Chasing my Planet!

My child's class was recently introduced to Cartesian coordinates in Math. And in our coding class, we have been practicing interactive programming for the last few weeks. So, I thought of putting together a very simple template that  combines both the concepts, that the kids could then remix...  Pac-Man is Chasing my Planet! was the result... took me less than 10 minutes to put together and the kids loved it.

We went through the Pac-Man template code as a group & discussed the use of the XY coordinates. I showed the kids how the XY coordinates displayed under the Scratch animations area change, as I move the cursor around on the screen. Our discussion then proceeded along the following lines:

• If I wanted my sprite (the planet, in this case) to move anywhere the cursor moves, what values should I use for the sprite's X and Y coordinates?
• The above point was also a good place to talk about variables, and how the change of the cursor position is always reflected in the planet's position.
• Should I move the planet around for just a few times or all the time? What kind of a loop should I use here?
• How can I make Pac-Man always follow the planet? Which loop should I use?
• What values should I use for Pac-Man's X and Y coordinates?
• Here, the kids quickly saw that without a small degree of separation between the coordinate values of the planet & Pac-Man, the two sprites overlap each other.
• BTW, the "if-else" clause was purely optional, for those to wanted to add another level to their game. The majority went with just a "go to x() y()"
• And finally, the interactive part of the game... I put in the requirement that there should "a key press" or "the green flag click" to make the game start, and something similar to end the game.

In the next one hour, the children came up with multiple variations of the game, making their own sprites and designing various versions of tag... All in all, a very fun class for them and me to wrap up the school year.

Happy Summer!!