Unit 3 Lesson 26 Game Puzzle

I am perplexed with several issues in this code. Can someone tell me:

  1. Why does the chicken disappear when score gets to somewhere between 11 and 20? [I put log statements in, and the Y value goes negative]
  2. Why does the code not complain about the sprites ‘leftEdge’ or ‘rightEdge’ that don’t exist?
  3. How can you call a function ‘createEdgeSprites’ that doesn’t exist?

PS. I commented out code for #2 and #3 and problem #1 still exists.

Link to code: Game Lab - Code.org


I like this game concept. Looks like fun!

Here’s some help on your questions.

  1. I think the offending code is on line 146. When the avoid sprite leaves the bottom of the screen, the chicken’s y position is changed. Is that the intended behavior?

  2. leftEdge and rightEdge do exist as soon as you use the “createEdgeSprites” block. Here’s the documentation that explains that. createEdgeSprites

  3. createEdgeSprites is a “built-in” function. It was created by the programmers who created GameLab. The code for it is in a library “under the hood” and abstracted away so students don’t need to worry about the code, but can just use it and know that it works.

Hope this helps!


Wow, thank you! I totally missed that! I looked at that code many times, and my mind obviously read what I wanted to see.

Thanks for the info on createEdgeSprites as well. I didn’t know about that. It does make me wonder where my student found it…

If your students remix a project, all of the blocks show up (including that one). They can also type in those commands in text mode, so if they saw it in the gallery or if they saw it in the documentation, they would know it exists as well.

It can come in handy, so it’s good that they discovered it!