Unit 6 Lesson 8 (21-22 version)

Unit 6 Lesson 8 codes a function called movePlayer which passes a parameter called player. Where does the value of player come from? I read in an earlier course version that it comes from the ID of the game screen. How does it know to get it from THERE? How would a variable know to get a value from a screen unless you tell it to? Why does the variable, player, not need a “var” definition?

NEVERMIND! As usual, after I embarass myself in front of the entire CSD community, I find the answer. The value is passed in line 10 and 15 of the code. The value goes out as “red” or “blue” and comes IN to the function as “player”. I get it now. Sorry to bother you all.

2 Likes