# chapter 7: repetition 7.1 definite loops (counted) 7.2 conditional loops (indefinite)

Post on 24-Dec-2015

214 views

Category:

## Documents

2 download

Tags:

• #### time eatat flashes

Embed Size (px)

TRANSCRIPT

• Slide 1
• Chapter 7: Repetition 7.1 Definite loops (counted) 7.2 Conditional loops (indefinite)
• Slide 2
• Why is Loop also called Counted Loop A.The loop makes things happen an indefinite number of times dependent on object positioning B.The loop makes things happen exactly 10 times C.The loop makes things happen a definite number of times
• Slide 3
• The program below has a guy walk toward a girl waving A.Before he walks toward her B.As he walks toward her C.Once he finishes walking toward her
• Slide 4
• When the code is done, how far will the guy have walked? A.2 meters B.5 meters C.7 meters D.10 meters
• Slide 5
• A blinking neon sign
• Slide 6
• What does this code do? How many times does it flash Start off with 3-D text objects at opacity 0 (invisible)
• Slide 7
• How many times does it flash EatAtJoes A2 times3 times B2 times6 times C3 times2 times D3 times6 times STOP, ASK PARAPHRASE Another EXAMPLE (change the #s)
• Slide 8
• How can I mess around with this code? Make EatAt flash and disappear, before Joes flashes 3 times. Make EatAt appear at the same time as Joes flashes 3 times Make Joes come on first, and EatAt flash several times while Joes is on Change the number of times each flashes Add a third 3-D text saying Crab Shack and have that flash 5 times for each time EatAt flashes 1 time Add a third 3-D text saying Crab Shack and have that flash 5 times for each time Joes flashes 1 time
• Slide 9
• Bunny Square Dance We want to direct the bunny to hop in a square pattern. The length of each side of his square should be 5 hops. Heres the structure of our code, what numbers would you put in for each missing number?
• Slide 10
• Outer Loop countInner Loop countTurn parameter A45.25 B451 C54 D541 Goal: Hop in a square, 5 hops on each side
• Slide 11
• What does this code do? A.Makes the guy move up close to the girl B.Makes the guy move toward the girl, but not all the way toward her C.Makes the guy move toward the girl and then go on past her D.I dont know 3 meters
• Slide 12
• The primary benefit of using a function to control the number of times a loop runs is A.The function can be used to make the loop run a fixed number of times B.The state of the world can be used to calculate how many times a loop should run C.The function can be used to allow the loop to run forever. D.I dont know STOP, ASK PARAPHRASE EXAMPLE
• Slide 13
• Games: Infinite loops and events Set up: A bunny, a cat, and a hawk all continuously move in squares 2.5 meters on a side moving forward.5 meters at a time An anvil hovers above their head Game: When I click on an animal, the anvil drops down and smooshes them (they go invisible) then the anvil returns to its place so I can click again An infinite loop is used to keep all the animals continuing to move in their square patterns
• Slide 14
• In the nested loops that control this code how many times should the loops run? Outer LoopInner Loop A55 B5Infinite C 5 D E: I dont know
• Slide 15
• Slide 16
• Slide 17
• After I click on an object (say the bunny) and call goBye that object stops moving around A.True B.False C.I dont know

Recommended