Game Controller

Scratch and Snap! enable students to create physical devices with the Hummingbird that interact with programs that also display information on the computer screen. Students can be challenged to create their own video game, complete with controller! One example is shown here, but students will come up with many other creative ideas.

In this game, two Hummingbird sensors are used to control the movement of a cat sprite on the screen. The user moves the cat to try to catch a mouse that appears at random screen locations. Hummingbird Pong, which is included in the Birdbrain Scratch .zip file, is another example of a game in which a Hummingbird sensor is used to control a sprite on the screen.

This game uses a controller that consists of two Hummingbird rotary knobs. One knob controls the vertical movement of the cat sprite, and one controls the horizontal movement.

Math operators can be used to transform the output of a Hummingbird sensor into x- and y-coordinates on the Scratch screen. In the expressions below, the value of the rotary knob on port 1 (0 to 100) determines the x-coordinate of the sprite (-240 to 240). The value of the rotary knob on port 2 (0 to 100) determines the y-coordinate of the sprite (-180 to 180). These expressions are placed within a go to block in Scratch.

At the start of the game, the mouse appears in a random position. The play must use the rotary knobs to move the cat to touch the mouse. When this happens, the player scores a point, and the mouse moves randomly to a new position. If the user scores 20 points within 30 s, he or she wins the game.  

This project could be extended to add more features to the controller! For example, LEDs on the controller could flash when the user scores a point. A student could also incorporate another sprite as the “villain.” Collisions with the villain could cause the player to lose points. Vibration motors could even be added to the controller to provide force feedback when a player gains or loses points.

This project is aligned with Common Core math standards that involve arithmetic and algebraic expressions (5.OA.A, 6.EE.A, and 7.EE.B); proportions (6.RP.A and 7.RP.A); and the coordinate grid (5.G.A and 6.NS.C). In addition, this project aligns with the Next Generation Science Standards for engineering at all grade levels (3-5-ETSI-1, 3-5-ETSI-2, 3-5-ETSI-3, MS-ETSI-1, MS-ETSI-2, MS-ETSI-3, MS-ETS1-4, and HS-ETSI-2).