I am struggling with helping my student find the error in the code in my student’s project. His character, Pennywise, keeps sinking. We expected this character not to sink based on other projects we have made. We have tried a few things with and and or, to no success. We have looked for other things affecting Pennywise’s y position too but cannot find any. Your advice is appreciated
The student based their gravity off the side scroller project. I am not sure what we are missing
Looks like a fun game! The sinking is caused by line 51. When Pennywise hits the apex of his jump, the velocity is set for him to go down, but you don’t have any lines of code telling him what to do when he reaches the bottom again.
It might seem like the conditional in line 44 would handle that, but that code is only executed once … right after the space bar is clicked. You need code to handle Pennywise falling that is outside of that conditional.
Hope this helps!
Why does the similar code work in the other game with the frog? That’s where I am at a loss.
Look at lines 35 & 36 of the student’s game … They are checking for the space bar before checking for the y position. In the frog game, it’s the other way around. Flip them and I’m guessing it will work.
Thank you so much. I needed another set of eyes.