Lesson 28: Student self-made game not working correctly

My student is trying to get the HP to go down when shadeSoul is touching zote.

However, it is only working when the knight is touching zote. He wants it to work even if zote is not touching the knight.

In order to get shadeSoul to appear, zote needs to touch the knight. Press the x key three times to power up, and then press the a key for shadeSoul to go across.

Any help you can provide would be appreciated! :slight_smile:

I forgot to put a link to the student’s code…Sorry! It’s been a long day. https://studio.code.org/projects/gamelab/uh-zwSNNKWQ0MuviJgydxAw-Prp6YR2dIwxWRdsDGYQ

There’s a lot going on here! It was a little tricky for me to keep track of which sprite was which to try and debug, but I did notice one thing that very well could be the issue.

The sprite shadeSoul is created three separate times … lines 36, 215 and 229. Although some of these may be functions and may not be called every time, it is best practice to only create a variable (sprite) one time … usually at the beginning of the code… and then update the values in other parts of the code. If you have two different instances of the sprite present in the memory at once, it’s very unpredictable what may happen and this is a common result … collisions are ignored.

Maybe suggest they update the code so the variable is only declared a single time and go from there, but we’re happy to take another look if they try that and it still isn’t working.

Mike