Middle School course

Programming 301

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

Answer Key

Module 2: Looping Knight Moves

Module 3: Knight Attack Functions

Module 4: Zombie Survival

Module 5: Animation Control

Module 6: Quiz

1. Charlie wants to program his knight to attack when he presses the spacebar. Which group of code blocks will program the knight to play his attack animation?

  • {"func":"registerKeyTrigger","values":[{"type":"choice","value":"space"}],"next":{"func":"blockLooksSwitchCostume","values":[{"type":"string","value":"attack 1"}],"next":{"func":"blockControlRepeat","values":[{"type":"number","value":"7"}],"containers":[{"func":"blockLooksNextCostume","next":{"func":"blockControlWait","values":[{"type":"number","value":".3"}]}}]}}}
  • {"func":"registerKeyTrigger","values":[{"type":"choice","value":"space"}],"next":{"func":"blockLooksSwitchCostume","values":[{"type":"string","value":"run 1"}],"next":{"func":"blockControlRepeat","values":[{"type":"number","value":"7"}],"containers":[{"func":"blockLooksNextCostume","next":{"func":"blockControlWait","values":[{"type":"number","value":".3"}]}}]}}}
  • {"func":"registerKeyTrigger","values":[{"type":"choice","value":"space"}],"next":{"func":"blockControlRepeat","values":[{"type":"number","value":"10"}],"containers":[{"func":"blockLooksNextCostume"}]}}
  • {"func":"registerKeyTrigger","values":[{"type":"choice","value":"space"}],"next":{"func":"blockControlRepeat","values":[{"type":"number","value":"7"}],"containers":[{"func":"blockLooksSwitchCostume","values":[{"type":"string","value":"attack 1"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":".3"}]}}]}}

2. What's the difference between the {"func":"blockControlForever","containers":[null]} and {"func":"blockControlForeverIf","values":[{"type":"boolean","value":"false"}],"containers":[null]} blocks?

  • The {"func":"blockControlForever","containers":[null]} block will run until the end of the program, while the {"func":"blockControlForeverIf","values":[{"type":"boolean","value":"false"}],"containers":[null]} block will run as long as its condition is satisfied
  • The {"func":"blockControlForeverIf","values":[{"type":"boolean","value":"false"}],"containers":[null]} block will run until the end of the program, while the {"func":"blockControlForever","containers":[null]} block will run as long as its condition is satisfied
  • The {"func":"blockControlForever","containers":[null]} block and the {"func":"blockControlForeverIf","values":[{"type":"boolean","value":"false"}],"containers":[null]} block will both run even after the program finishes
  • The {"func":"blockControlForever","containers":[null]} block will run even after the program finishes, while the {"func":"blockControlForeverIf","values":[{"type":"boolean","value":"false"}],"containers":[null]} block will run as long as its condition is satisfied

3. What is the difference between the {"func":"registerFlagTrigger","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueSensingKeyPressed","values":[{"type":"choice","value":"space"}]}],"containers":[{"func":"blockLooksHide"}]}} and {"func":"registerKeyTrigger","values":[{"type":"choice","value":"space"}],"next":{"func":"blockLooksHide"}} blocks?

  • The two code blocks do the same thing - they both make the actor hide when space is pressed
  • The first block will make the actor hide as soon as the program starts, while the second block will make the actor hide only when space is pressed
  • The first block will not make the actor hide, while the second block will make the actor hide only when space is pressed
  • The two code blocks do the same thing - they both make the actor hide when the program is started

4. What would happen if you replaced {"func":"registerFlagTrigger","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueSensingMouseDown"}],"containers":[{"func":"blockLooksNextCostume"}]}} with {"func":"registerFlagTrigger","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueSensingKeyPressed","values":[{"type":"choice","value":"space"}]}],"containers":[{"func":"blockLooksNextCostume"}]}}?

  • The actor would change costumes whenever the spacebar is pressed
  • The actor would change costumes whenever the mouse button is pressed
  • The actor would not be able to change Costumes
  • The actor would change Costumes as soon as the program starts

5. Quentin is trying to make an Actor face right every time they bump into another Actor. Which of these blocks does he need in his code to make the Actor face right?

  • {"func":"blockMotionPointDirection","values":[{"type":"string","value":"90"}]}
  • {"func":"blockMotionMove","values":[{"type":"number","value":"10"}]}
  • {"func":"blockMotionGoTo","values":[{"type":"number","value":"0"},{"type":"number","value":"0"}]}
  • {"func":"blockMotionPointTowards","values":[{"type":"string","value":"mouse-pointer"}]}

6. True or false: If an Actor with this code block only had two Costumes, we would be able to replace the {"func":"blockLooksSwitchCostume","values":[{"type":"string","value":""}]} block with the {"func":"blockLooksNextCostume"} block. {"func":"registerKeyTrigger","values":[{"type":"choice","value":"space"}],"next":{"func":"blockLooksNextCostume","next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}],"next":{"func":"blockLooksSwitchCostume","values":[{"type":"string","value":"costume 2"}]}}}}

  • True
  • False

7. What key needs to be pressed to change the costume of this Actor? {"func":"registerKeyTrigger","values":[{"type":"choice","value":"left arrow"}],"next":{"func":"blockLooksNextCostume","next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}],"next":{"func":"blockLooksSwitchCostume","values":[{"type":"string","value":"costume 2"}]}}}}

  • The left arrow key
  • The space bar
  • The right arrow key
  • The return key

8. What would happen if we removed the 'Wait' block from this code block? {"func":"registerKeyTrigger","values":[{"type":"choice","value":"left arrow"}],"next":{"func":"blockLooksNextCostume","next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}],"next":{"func":"blockLooksSwitchCostume","values":[{"type":"string","value":"costume 2"}]}}}}

  • The actor would change costumes too quickly to see
  • The actor would change costumes slowly
  • The actor would not change costumes
  • The actor would change costumes three times

9. Which block is needed to change to a specific costume?

  • {"func":"blockLooksSwitchCostume","values":[{"type":"string","value":""}]}
  • {"func":"blockLooksNextCostume"}
  • {"func":"blockSoundPlay","values":[{"type":"string","value":""}]}
  • {"func":"registerFlagTrigger"}

10. True or false: An Actor can have more than one costume.

  • True
  • False

11. True or false: An Actor cannot use the {"func":"blockLooksSwitchCostume","values":[{"type":"string","value":""}]} block if they only have one costume

  • True
  • False

12. Henry wants to play the attack animation when the spacebar is pressed, but the Actor does not correctly change to the first costume of the animation. Which of these blocks is he missing?

  • {"func":"blockLooksSwitchCostume","values":[{"type":"string","value":""}]}
  • {"func":"blockLooksNextCostume"}
  • {"func":"blockLooksHide"}
  • {"func":"registerFlagTrigger"}

13. What can we replace this block with to make the Actor move more smoothly? {"func":"registerKeyTrigger","values":[{"type":"choice","value":"up arrow"}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"5"}]}}

  • {"func":"registerFlagTrigger","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueSensingKeyPressed","values":[{"type":"choice","value":"up arrow"}]}],"containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"5"}]}]}}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueSensingKeyPressed","values":[{"type":"choice","value":"up arrow"}]}],"next":{"func":"blockControlRepeat","values":[{"type":"number","value":"10"}],"containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"5"}]}]}}
  • {"func":"registerFlagTrigger","next":{"func":"blockControlIf","values":[{"type":"wrapper","func":"valueSensingKeyPressed","values":[{"type":"choice","value":"up arrow"}]}],"containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"5"}]}]}}
  • {"func":"registerTrigger","values":[{"type":"wrapper","func":"valueSensingKeyPressed","values":[{"type":"choice","value":"up arrow"}]}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"5"}]}}

14. What does this code block do? {"func":"registerFlagTrigger","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueSensingTouchingSprite","values":[{"type":"string","value":"mouse-pointer"}]}],"containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"10"}]}]}}

  • It would make the actor move forward whenever it is touching the mouse
  • It would make the actor turn whenever it is touching the mouse
  • It would make the actor flip whenever it is touching the mouse
  • It would make the actor change costumes whenever it is touching the mouse

15. What would happen if we removed the {"func":"blockLooksSwitchCostume","values":[{"type":"string","value":"jump 1"}]} block from this code block? {"func":"registerFlagTrigger","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueSensingKeyPressed","values":[{"type":"choice","value":"space"}]}],"containers":[{"func":"blockLooksSwitchCostume","values":[{"type":"string","value":"jump 1"}]}]}}

  • The actor will not change at all when space is pressed
  • The actor will change to the first jump costume when space is pressed
  • The actor will change to the next costume when space is pressed
  • The actor will disappear when space is pressed

U.S. Standards

  • CCSS-Math: MP.1
  • 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 5: Conditional Loops

Course: | Web

  • Concepts
  • Looping Knight Moves
  • Knight Attack Functions
  • Zombie Survival
  • Animation Control
  • 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.