Unit 3 Lesson 22 help

Let me see if I can tackle this…

First, I usually like to go top to bottom to find the error but this one was harder to do that because of the function calls. So, I tried to figure out what the student wanted to do with the axe (b). It looks like it was a weapon. My thinking was the overlap error was generated because the boi and axe were connected so I thought if you separated them in the conditional, it may work (or at least be more accurate). So, my thinking said “if the axe is visible AND it is touching the alien, then you should call the function hit”. The student had the function hit running at the top of the draw loop. When I changed this, an error came up about alien not being a function. I found a great post by @elizabeth_admin that talks about his. Your student did have alien=200 (vs alien.x or alien.y). When I took out this line, there does not seem to be an error but I am open to the idea that one is still there if the game is played enough. Also, my version takes out the fun variable (that randomly generates an alien animation) but it should go back in without a problem.

Also, many of the sprite.visible properties are set to a number but it is a boolean property meaning it is either true or false only (not a number). Here is some documentation on sprite.visible.

Let us know if these tips help out or if I missed the mark (or the alien-ha!) Here is my remix: https://studio.code.org/projects/gamelab/ags5A5O-qzXbi3rMVwbYH8SPW61r7uk38Yrw4CwYGYk

1 Like