Unit 3, Lesson 15

When working with puzzle 11 and the frog velocity coding, my students unable to get the frog to stop moving, even with frog.velocityY = 0 set in the else portion of the if statement.

Is this a glitch? all the other code works fine.

Hi!

Can you give an example by clicking the “Share” button on one of the levels where this is happening and pasting the link here?

Elizabeth

https://studio.code.org/projects/gamelab/l87jIV_S0m9YDyG6ClUZcJcLojLH4igN2QFTunLC13k

The frog jumping appears to be working on this one. The only issue I see is that the mushroom isn’t moving because its position isn’t being changed with the counter pattern.

The directions say to make the frog jump when the up key is pushed and then stop. the velocityY = 0 isn’t working to make the frog stop. or is that not the intent?

It makes the frog stop when it is back on the ground. Without that line of code, the frog would fall through the ground off the screen.

So, if the frog is on the ground, two things could possibly happen.

  1. If the up key is pressed, it starts to move up.
  2. Else, it stops where it is.
1 Like

A post was merged into an existing topic: Code not running in blocks view, but will run after pressing show text

I am experiencing the same issue with lesson 15 level 13. I suspect that it is a bug of some kind. Can I get some clarification? The directions clearly state that if the up key in no longer being pressed then the frog should stop moving. However, using frog.velocityY=0 as the then statement has no effect. I have used multiple browsers. Can you explain if this is working as designed and why the sprite does not stop going up after the key is no longer being pressed?
21%20AM

1 Like

The frog should only stop if it is on the ground. The nested conditional means that two conditions have to be true for the frog to stop from the code on line 25. First, the frog must be on the ground (y position greater than 324). Second, the up key should not have gone down. If the frog is in the air, this condition is not triggered and it does not stop.

The Instructions are confusing. The 2nd bullet under the 1st bullet reads in such a way that you would think that the frog should stop when the up arrow is released.

" Make the frog jump up when the user presses the arrow key.
" Make the frog stop moving otherwise."

Clearly the nested loop will not allow this once the sprite begins moving.

Perhaps additional instructions would help clear the confusion

11

3 Likes

Hi Ron,

Thank you for the suggestion. I have forwarded this to the curriculum team.

Karen

I have the same problem. I am glad that I am not the first one to think that the frog stops when velocityX=0; Anyways, I agree that the instructions are little confusing. If I was a student I would be stuck on the 1st bullet and not move forward with out realizing this if condition is going to come into picture on the 2nd bullet. Thanks for sharing with curriculum team.

1 Like

I thought I was missing something. Been working on trying to get the frog to stop for about 15 minutes now…

2 Likes

What if the frog begins to come down sooner than <30 like this
// if the frog gets high enough
// send it back down
if (frog.y < 225) {
frog.velocityY = 1;
}

that would give it enough room to get over the mushroom so it can come down sooner and jump the mushroom again. Just a thought I had and it seems to work.

1 Like