U3L18 Level 11a question

Could someone please help by explaining why does the sprite leave the screen in 11a, instead of going around in a loop. Thank you!

https://studio.code.org/projects/gamelab/_vqy-4HRqeiEd8drmDBzyulJii1Wajbq1I9SlQ0QuIM

@vjay,

Good question! I set up some watchers (see image below) and after the first loop, you will notice that alien.x and alien.y are both less than 50. The velocityY therefore is always set to -3 based on your code because alien.x stays < 50.
Screen Shot 2020-11-16 at 3.22.10 PM
I’ll bet with a little tweaking, you can figure out how to fix that!

Mike

I don’t see why it’s working for the other three conditionals, but not for the last one. I’ve tried everything I could think off…

It’s probably the order of the code. Since it’s the last one run, it’s the last condition checked and it takes precedence over the other codes that are run.

You may look at adding multiple conditions… (if alien.y < 50 and alien.x < 50)… The last one would be (if alien.y >350 and alien.x <50)…

Does this help?

Mike

1 Like