L9 Counter Pattern

Post date: May 30, 2020 12:17:47 AM

Objectives

  • Students will be able to:Use the counter pattern to increment or decrement sprite properties

  • Identify which sprite properties need to be changed, and in what way, to achieve a specific movement.

  • Identify starting X and Y location and adjust to show meaningful movement.

Not only do you have the ability to change the X and Y location of a sprite to show meaningful movement, but you can also change parameters such as rotation, scale or size or even color.

The term Counter Pattern refers to the pattern of events that is scripted and will have the desired result. It is used to increase the value of a variable by a number you specify. It also uses a math block to identify the change.

A variable is created and identified as counter and it gets the number 0. The counter variable is used for two things. It not only controls the number shown but the size. As the counter number is increased in increments of one, the size also changes. This Code is used to simply change the location so the sprite moves from side to side. Fly.X position gets the number fly's X position -1 X. This code will move the sprite to the left by -1 X each time it is run.

Programming sprites to rotate is just like programming them to move. The program knows sprites rotation gets the value sprite rotation +1. Each repeat of the functions adds 1 to the sprite's rotation.

Using Watchers and Debugging with Watchers: The watcher code lets you have your program display variables for you. This is a very useful tool for when you want to know what your program is doing with the variables that you don't know.