Problem with looping and change direction

I can’t figure out why this will not loop.
I want the boat to go right and left and change direction to suit the movement. I’m going to include it as part of the final project in unit 3 Lesson 22 CSD.

Regards
Glen

Also I saw a plane moving in similar way in one of the lessons. I may have been using the ‘rotateToDirection’ block.
I’d like to review it but can’t seem to find it.

Grateful for any help.
Glen

@glen.strickland,

The problem with your loop is that once the boat.x > 390, you set boatLeft.x equal to 390 and change the boatLeft velocity to -1, but the loop continues to run because boat.x is still greater than 390, so your velocity is -1, but that loop keeps setting boatLeft back to 390 so it never gets to leave the harbor … lol.

rotateToDirection may work, but I like using only one sprite and using the mirrorX block to flip it when you get to that spot … There are certainly more than one ways to handle this, but here’s a version I made:

Boat Turns

Mike

1 Like