Unit 5 Lesson 16 Level 7 Example Solution

csp-unit-5-lesson-16
#1

The example solution provided for Unit 5 Lesson 16 Level 7 appears to show a format for calling a function that includes setting a variable. I do not believe students have been exposed to this format previously.

image

Please provide another example of how this task can be accomplished using a format they are familiar with. Also, if they have been exposed to this previously please tell me which lesson.

Thank you,
Beth

#2

The xloc and yloc variables are global and can be accessed in any function. The xloc = constrain(xloc, 0, 320) restricts the turtle with in the screen by not exceeding the max value of 450 on min value of 320. The variables xloc and yloc are not new variables. They are just being reassigned new values based on the onEvent call back function. Review the lessons on functions in Unit 3 and the moveTo() documentation. Those should provide further explanation.