Games & Animation Lesson 25

I have 2 student’s with the same problem. In the Defender Game on Lesson 25, the up arrow nor the left arrow work.

Changed keys from arrows to the letters (key up “w”, etc.) and still no luck.

Has anyone else had issues with this and what was your solution?

@tfrederick2 ,

I’d be happy to take a look at it if you are able to fill in the information requested below and send us the “share” link from one or both students.

thanks!

Mike

[Posts in the debugging category need to have the following pieces of information included in order to help other teachers or our moderator team best help you. Feel free to delete everything in brackets before posting your request for debugging help.]
Link to the project or level: [replace with link to the curriculum or get the “Share” link to a project]
What I expect to happen: [replace with a detailed description of the behavior you’re trying to create]
What actually happens: [replace with a detailed description of what actually happens when the code runs including any errors or unexpected behavior]
What I’ve tried: [replace with a detailed description of what you’ve already tried to do to solve the problem]

Thank you. Here is one student’s link - Game Lab - Code.org.

Like I said, today we changed from the arrow keys to the letter keys and the same problem…no moving up and no moving left.

Now I’m getting an error message saying that that link may not be shared properly. Can you see if sharing is enabled and try again?

Sorry.

Mike

I am copying from my Teacher Dashboard - Game Lab - Code.org.

I may have to wait until Wednesday to check the student’s computer.

I may have found her error, but it still does not explain why up and left do not work.

Ok… Below is the message I get. If you can get the “share” link from the student computer, I’m sure we can help you figure out why up and left aren’t working.

Screen Shot 2022-05-02 at 11.02.23 AM

Mike

OK - here is another link from the student - Game Lab - Code.org

I was out yesterday.

THank you again.

Got it. Thanks!

So, what is happening is that you have 4 independent conditional clauses. Two of them control the left and right movement and the other two control the up and down movement.

However, they conflict with each other. Your first conditional (up, I believe) says “if w is pressed, move up, otherwise, don’t move.” Then, immediately after, you have one that says “if x is pressed, move down, otherwise don’t move.” The computer executes those two commands in order and the final command when you press w (since x isn’t pressed) is to not move. So, it basically ignores the command to move up.

You can fix this by using “nested conditionals”. Try a condition like “IF w pressed, move up, ELSE if x pressed, move down, ELSE don’t move.”

When I did that (and also fixed the left and right conditionals the same way), I got a character that could move in all 4 directions.

Good luck and check back in if you need any further assistance.

Mike

Thank you! I will have her try this tomorrow.