Middle School course

Programming 301

  • GRADES 7-8
  • BEGINNER
  • WEB
  • 17 LESSONS
Slide: 1 of

Answer Key

Module 2: Deflect the Fireball 1

Module 3: Deflect the Fireball 2

Module 4: Defeat the Trolls

Module 5: Fireball Tennis

Module 6: Quiz

1. Which of these properties can you check using the {"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":""},{"type":"string","value":""}]} block?

  • The current Costume number of the Actor
  • The current x position of the Actor
  • The current direction of the Actor
  • All of the above

2. Which of these two turn blocks are equivalent? (Choose 2.)

  • {"func":"blockMotionTurnCW","values":[{"type":"string","value":"180"}]}
  • {"func":"blockMotionTurnCCW","values":[{"type":"string","value":"180"}]}
  • {"func":"blockMotionTurnCW","values":[{"type":"string","value":"90"}]}
  • {"func":"blockMotionTurnCCW","values":[{"type":"string","value":"90"}]}

3. Which of these two turn blocks are equivalent? Remember that it takes 360 degrees to turn an entire circle. (Choose 2.)

  • {"func":"blockMotionTurnCW","values":[{"type":"string","value":"60"}]}
  • {"func":"blockMotionTurnCCW","values":[{"type":"string","value":"300"}]}
  • {"func":"blockMotionTurnCW","values":[{"type":"string","value":"180"}]}
  • {"func":"blockMotionTurnCCW","values":[{"type":"string","value":"0"}]}

4. Which block should you use to check the Costume number of an Actor from a different Actor?

  • {"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"costume #"},{"type":"string","value":"actor"}]}
  • {"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"costume name"},{"type":"string","value":"actor"}]}
  • {"type":"wrapper","func":"valueLooksCostumeNum"}
  • {"type":"wrapper","func":"valueLooksCostumeName"}

5. True or False: You can use the {"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":""},{"type":"string","value":""}]} block to check both the Costume number and Costume name of another Actor.

  • True
  • False

6. True or False: You can use the {"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":""},{"type":"string","value":""}]} block to check what direction another Actor is facing.

  • True
  • False

7. Which of these code block checks for when the knight is facing left?

  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"direction"},{"type":"string","value":"knight"}]},{"type":"string","value":"-90"}]}]}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"direction"},{"type":"string","value":"knight"}]},{"type":"string","value":"90"}]}]}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"direction"},{"type":"string","value":"wall"}]},{"type":"string","value":"-90"}]}]}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"costume #"},{"type":"string","value":"knight"}]},{"type":"string","value":"-90"}]}]}

8. Michael wants to program a Red Light, Green Light game where the player should move their character towards the traffic light only when it's green. If they move while it is red, they have to go back to the starting position. Which of these code blocks would Michael use to make the character react correctly to the red light?

  • {"func":"blockControlIf","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"costume name"},{"type":"string","value":"traffic lght"}]},{"type":"string","value":"red light"}]}],"containers":[{"func":"blockMotionGoTowards","values":[{"type":"string","value":"start"}]}]}
  • {"func":"blockControlIf","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"costume name"},{"type":"string","value":"traffic lght"}]},{"type":"string","value":"green light"}]}],"containers":[{"func":"blockMotionGoTowards","values":[{"type":"string","value":"start"}]}]}
  • {"func":"registerKeyTrigger","values":[{"type":"choice","value":"right arrow"}],"next":{"func":"blockMotionPointDirection","values":[{"type":"string","value":"90"}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}]}}}
  • {"func":"registerKeyTrigger","values":[{"type":"choice","value":"right arrow"}],"next":{"func":"blockMotionGoTowards","values":[{"type":"string","value":"start"}]}}

9. What does this code block do? {"func":"registerFlagTrigger","next":{"func":"blockMotionGoTo","values":[{"type":"number","value":"0"},{"type":"number","value":"0"}],"next":{"func":"blockMotionPointDirection","values":[{"type":"wrapper","func":"valueOpRandom","values":[{"type":"number","value":"1"},{"type":"number","value":"360"}]}],"next":{"func":"blockControlForever","containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}]}}]}}}}

  • The Actor will start off in the center of the screen and move forever in a random direction
  • The Actor will start off in the center of the screen and move to the right forever
  • The Actor will start in a random location and move forever in a random direction
  • The Actor will start off in the center of the screen and not move

10. Luke wants to program the ghost to move towards the knight only if the knight is on the right side of the screen. Which of these code blocks would we use to do this?

  • {"func":"registerFlagTrigger","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueOpGreater","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"x position"},{"type":"string","value":"knight"}]},{"type":"string","value":"0"}]}],"containers":[{"func":"blockMotionPointTowards","values":[{"type":"string","value":"knight"}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}]}}}]}}
  • {"func":"registerFlagTrigger","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueOpLess","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"x position"},{"type":"string","value":"knight"}]},{"type":"string","value":"0"}]}],"containers":[{"func":"blockMotionPointTowards","values":[{"type":"string","value":"knight"}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}]}}}]}}
  • {"func":"registerFlagTrigger","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueOpGreater","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"y position"},{"type":"string","value":"knight"}]},{"type":"string","value":"0"}]}],"containers":[{"func":"blockMotionPointTowards","values":[{"type":"string","value":"knight"}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}]}}}]}}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpGreater","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"x position"},{"type":"string","value":"knight"}]},{"type":"string","value":"0"}]}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}]}}

11. Jake wants to program a fireball to fly around the screen randomly. When it hits the wall, it should bounce off. If it hits the ghost, it should just pass through. Which of these code blocks could he use to program this behavior?

  • {"func":"registerFlagTrigger","next":{"func":"blockControlForever","containers":[{"func":"blockMotionPointDirection","values":[{"type":"wrapper","func":"valueOpRandom","values":[{"type":"number","value":"1"},{"type":"number","value":"360"}]}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}],"next":{"func":"blockControlIf","values":[{"type":"wrapper","func":"valueSensingTouchingSprite","values":[{"type":"string","value":"wall"}]}],"containers":[{"func":"blockMotionTurnCCW","values":[{"type":"string","value":"180"}]}]}}}}]}}
  • {"func":"registerFlagTrigger","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueSensingTouchingSprite","values":[{"type":"string","value":"wall"}]}],"containers":[{"func":"blockMotionPointDirection","values":[{"type":"wrapper","func":"valueOpRandom","values":[{"type":"number","value":"1"},{"type":"number","value":"360"}]}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}],"next":{"func":"blockMotionTurnCCW","values":[{"type":"string","value":"180"}]}}}}]}}
  • {"func":"registerFlagTrigger","next":{"func":"blockControlForever","containers":[{"func":"blockMotionPointDirection","values":[{"type":"wrapper","func":"valueOpRandom","values":[{"type":"number","value":"1"},{"type":"number","value":"360"}]}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}],"next":{"func":"blockControlIf","values":[{"type":"wrapper","func":"valueSensingTouchingSprite","values":[{"type":"string","value":"wall"}]}],"containers":[{"func":"blockMotionTurnCCW","values":[{"type":"string","value":"0"}]}]}}}}]}}
  • {"func":"registerFlagTrigger","next":{"func":"blockControlForever","containers":[{"func":"blockMotionPointDirection","values":[{"type":"string","value":"90"}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}],"next":{"func":"blockControlIf","values":[{"type":"wrapper","func":"valueSensingTouchingSprite","values":[{"type":"string","value":"wall"}]}],"containers":[{"func":"blockMotionTurnCCW","values":[{"type":"string","value":"180"}]}]}}}}]}}

12. What is the difference between the {"func":"blockMotionTurnCW","values":[{"type":"string","value":"90"}]} and {"func":"blockMotionPointDirection","values":[{"type":"string","value":"90"}]} blocks?

  • The {"func":"blockMotionTurnCW","values":[{"type":"string","value":"90"}]} block changes the Actor relative to its current direction, while the {"func":"blockMotionPointDirection","values":[{"type":"string","value":"90"}]} block is not dependent on the current direction of the Actor
  • The {"func":"blockMotionTurnCW","values":[{"type":"string","value":"90"}]} block is not dependent on the current direction of the Actor, while the {"func":"blockMotionPointDirection","values":[{"type":"string","value":"90"}]} block changes the Actor relative to its current direction
  • Both the {"func":"blockMotionTurnCW","values":[{"type":"string","value":"90"}]} and {"func":"blockMotionPointDirection","values":[{"type":"string","value":"90"}]} blocks change the Actor relative to its current direction
  • Both the {"func":"blockMotionTurnCW","values":[{"type":"string","value":"90"}]} and {"func":"blockMotionPointDirection","values":[{"type":"string","value":"90"}]} blocks are not dependent on the current direction of the Actor

13. Which block would you use to check if another Actor has the same Costume as your current Actor?

  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"costume name"},{"type":"string","value":"actor"}]},{"type":"wrapper","func":"valueLooksCostumeName"}]}]}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"costume name"},{"type":"string","value":"actor"}]},{"type":"wrapper","func":"valueLooksCostumeNum"}]}]}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpLess","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"costume #"},{"type":"string","value":"actor"}]},{"type":"wrapper","func":"valueLooksCostumeNum"}]}]}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"direction"},{"type":"string","value":"actor"}]},{"type":"string","value":"90"}]}]}

14. Which block would you use to check if another Actor is further to the right than the current Actor?

  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpGreater","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"x position"},{"type":"string","value":"actor"}]},{"type":"wrapper","func":"valueMotionXPosition"}]}]}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpGreater","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"x position"},{"type":"string","value":"actor"}]},{"type":"wrapper","func":"valueMotionYPosition"}]}]}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpGreater","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"y position"},{"type":"string","value":"actor"}]},{"type":"wrapper","func":"valueMotionXPosition"}]}]}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpGreater","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"y position"},{"type":"string","value":"actor"}]},{"type":"wrapper","func":"valueMotionYPosition"}]}]}

15. Tori wants to program a game where the controls are reversed. For example, if you tilt the device right, you should move left. When you tilt the device backward, you should move up. Which of these code blocks does NOT belong in her code?

  • {"func":"registerTiltTrigger","values":[{"type":"choice","value":"forward"}],"next":{"func":"blockMotionPointDirection","values":[{"type":"string","value":0}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}]}}}
  • {"func":"registerTiltTrigger","values":[{"type":"choice","value":"backward"}],"next":{"func":"blockMotionPointDirection","values":[{"type":"string","value":180}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":-10}]}}}
  • {"func":"registerTiltTrigger","values":[{"type":"choice","value":"left"}],"next":{"func":"blockMotionPointDirection","values":[{"type":"string","value":90}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}]}}}
  • {"func":"registerTiltTrigger","values":[{"type":"choice","value":"right"}],"next":{"func":"blockMotionPointDirection","values":[{"type":"string","value":-90}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}]}}}

16. Michael wants to program a Red Light, Green Light game where the player should move their character towards the traffic light only when it's green. If they move while it is red, they have to go back to the starting position. Which of these code blocks would Michael use to make the character react correctly to the red light?

  • {"func":"blockControlIf","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"costume name"},{"type":"string","value":"traffic lght"}]},{"type":"string","value":"red light"}]}],"containers":[{"func":"blockMotionGoTowards","values":[{"type":"string","value":"start"}]}]}
  • {"func":"blockControlIf","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueSensingSpriteProperty","values":[{"type":"choice","value":"costume name"},{"type":"string","value":"traffic lght"}]},{"type":"string","value":"green light"}]}],"containers":[{"func":"blockMotionGoTowards","values":[{"type":"string","value":"start"}]}]}
  • {"func":"registerTiltTrigger","values":[{"type":"choice","value":"right"}],"next":{"func":"blockMotionPointDirection","values":[{"type":"string","value":"90"}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"10"}]}}}
  • {"func":"registerTiltTrigger","values":[{"type":"choice","value":"right"}],"next":{"func":"blockMotionGoTowards","values":[{"type":"string","value":"start"}]}}

U.S. Standards

  • CCSS-Math: MP.1, MP.2, MP.4
  • CCSS-ELA: RI.7.4, RI.8.4, 6-8.RST.3, 6-8.RST.4, 6-8.RST.7
  • CSTA: 2-AP-10, 2-AP-12, 2-AP-13, 2-AP-15, 2-AP-16, 2-AP-17
  • CS CA: 6-8.AP.12, 6-8.AP.13, 6-8.AP.15, 6-8.AP.16, 6-8.AP.17
  • ISTE: 1.c, 1.d, 4.d, 5.c, 5.d, 6.b

U.K. Standards

Key stage 3
Pupils should be taught to:
  • design, use and evaluate computational abstractions that model the state and behaviour of real-world problems and physical systems
  • understand several key algorithms that reflect computational thinking [for example, ones for sorting and searching]; use logical reasoning to compare the utility of alternative algorithms for the same problem
  • undertake creative projects that involve selecting, using, and combining multiple applications, preferably across a range of devices, to achieve challenging goals, including collecting and analysing data and meeting the needs of known users
  • create, reuse, revise and repurpose digital artefacts for a given audience, with attention to trustworthiness, design and usability
  • understand a range of ways to use technology safely, respectfully, responsibly and securely, including protecting their online identity and privacy; recognise inappropriate content, contact and conduct, and know how to report concerns
Key stage 4
All pupils must have the opportunity to study aspects of information technology and computer science at sufficient depth to allow them to progress to higher levels of study or to a professional career. Pupils should be taught to:
  • develop their capability, creativity and knowledge in computer science, digital media and information technology
  • develop and apply their analytic, problem-solving, design, and computational thinking skills
  • understand how changes in technology affect safety, including new ways to protect their online privacy and identity, and how to report a range of concerns

Lesson 7: Actor Properties

Course: | Web

  • Concepts
  • Deflect the Fireball 1
  • Deflect the Fireball 2
  • Defeat the Trolls
  • Fireball Tennis
  • Quiz

Description

An advanced introduction to programming for middle school. Introduce programming fundamentals to your class as they build two arcade-inspired games from start to finish. The Adventure Game features a knight who has to defeat enemies to reach treasure. Students program arrow keys, fluid motion, hero and enemy behavior, and winning conditions. In Dragon Attack, they define multiple levels and lives, and program a boss enemy, while learning about variables and cloning.

Topics

  • Events
  • Keyboard and mouse interaction
  • Conditional loops
  • Nested loops
  • Sending and receiving messages
  • Fluid motion
  • Parallax scrolling
  • Local and global variables
  • Functions
  • Object cloning

What Students Learn

  • Build complex multi-level games
  • Use variables to keep score
  • Use cloning to create actors programmatically
  • Build algorithms using complex conditional logic
  • Understand parallelism with multiple scripts
  • Program different behaviors for different actors
  • Publish projects to the Web
  • Troubleshoot and debug programs

Technical Requirements

* Online courses require a modern desktop computer, laptop computer, Chromebook, or Netbook with Internet access and a Chrome (29+), Firefox (30+), Safari (7+), or Edge (20+) browser. No downloads required.