Unit 3 Lesson 15: Keyboard Input - Stage 7B

Hello I have another student who wants to change the sprite by pressing both the up arrow and the left arrow (or right) to change the sprite. How can this be done?

@rdiaz1,

For something like that, you may have to have nested conditionals. Here is some pseudo-code.

If up key pressed
check if left arrow (also) pressed
If so, change sprite animation

So, it goes through the code and hits the first conditional and if the up key isn’t pressed, it skips the 2nd conditional and continues on. However, if the up key is pressed, it looks at the second conditional to see if the left key is also pressed. If so, it changes the sprite animation.

That’s about how much help I would give them and then I would let them try it out on their own. If they give it a shot and it isn’t working, have them share the link to the project and I’d be happy to look at their attempt.

Mike