Help Me Fix This

Hello!

I am working on a practice project being recreated by a class of elementry aged coders this spring. It is a simple tilemap with a car navigating obstacles. The goal is to teach them how the programs works and how to fix minor issues in their projects. Many of them have little experience with tech whatsoever. In making this practice project I have run into a little problem. I have coded it to move through obstacles, move forward at a stable pace, have a defined start and end, ect.

Can y’all help me add to the code so that when the students hit a wall it reverses for a second or two, and then starts forward again… I have so much trouble with the pause and restart mechanics!

2 Likes

Here I fixed it for you.

I installed the timer extension and made a on game update block that handles the logic

If you want to modify how far back the car moves before resuming, just change the timer. You can also add a second timer to make the car wait before turning around. Hope this helps!

1 Like

I have fixed it. This is the picture of what I added:

If you instead did something like this:

Then, since the pause block would pause the game entirely, it would just pause the game, then after 300ms, it would unpause and have the car go forward.

If you would like to know how to put the extension on a project, click the extensions choice in the toolbox:

Then scroll down to the timer extension:

and press it, then it should download directly to your project!

Here’s the game link:

1 Like

Hello! One last ask for help– now I can’t get it to recognize my “end tile” to trigger the game to win. Any suggestions?

1 Like

I’m late to the party here, but the ‘on overlap end tile’ block wasn’t registering because the type of the sprite has to be car (not player) and when the car hits the end tile, it will actually be at the car’s center rather than its right.
With those changes it works for me now :smiley:

1 Like

It’s because you are triggering it in a weird way. :slightly_smiling_face: You have it so that when the car hits a wall, you check if the tile to the right is the end tile. It’s not working because the tile isn’t marked as a wall in the first place. But instead of going back to the tilemap and doing that, there’s a much simpler way to write this code:

Here’s the share link for the fixed project.

2 Likes