Unit 3 - Lesson 20 Mini Side Scroller Question

In the example bubble one, how does the frog keep coming down to the ground? When I did it, I can continually press the up arrow without him touching the ground. Is it a while loop?

If you continue through lesson 20, you will see how that sprite movement is done (how the frog keeps coming down to the ground). It will show you specific steps in bubble 4.

The background and sprites are in a draw loop. The movement of the frog is done with conditionals that check where the frog is.

Did this answer your question? If not, it is helpful if you share your code here, so we can take a look at it to see what’s happening. In the upper left hand corner there is a share button where you can get a link to share it.

Not really. I watched a YouTube video and this is what I needed. Hard to tell from the comments they give you.

7e99b00a-96eb-4ae3-9221-14ccdd5f8d2e.png

Ok, looks like you are all set. Let me know if you have any more questions about this lesson.

Hello. I believe the above solution is from previous years. It is much simpler to just use 3 if statements, making sure they are in the correct order. Using 3 if statements actually follows the current year’s lesson 20 instructions on puzzle 4. This is because students have not learned nested ifs yet. The comments show the students what order to put the if blocks in. In order for the game to work, the if statements must be in a SPECIFIC order and the value that tests whether the frog is at the bottom must be the same y position where it started. The game will work a little differently but the students will still learn how to build a complete game. I’ve pasted the 3 if statements below:

// JUMPING
// if the player has reached the ground
// stop moving down
// NOTE player sprite was created at the y position of 325
if (player.y > 325) {
player.velocityY = 0;
}

// if the player presses the up arrow
// start moving up
if (keyWentDown(“up”)) {
player.velocityY = -5;
}

// if the player reaches the top of the jump
// start moving down
if (player.y < 100) {
player.velocityY = 5;
}

Hello. I have created a guided worksheet for students to use with a partner to help them complete lesson 20 successfully, hopefully with less help from the teacher. It uses a “coding block” bank (like a word bank) of every coding segment they will need to complete it. They still had to work to complete it, but they liked having the blocks available. I’ve shared the google link below:

2 Likes