Step 5

Grabbing the Green Disk


Now that we got one of the red disks, let’s complete the code to get one of the green ones.

Luckily, the green disk is also directly in front of the square we need to drop it in.

Do you see any simliarities between the red and green disks on the map? Just like for the red disks, we need to turn into the green square and then we can use the same code we used for the other two disks!

Moving to the green square is exactly the same as moving to the red square, so we can actually use the exact same code here and it will work!

See if you can complete the code to get the other green squares. If you do, see if you can find a way to further improve your code. As you have seen, whenever things have patterns/similiarites, it can really help making the coding a lot easier. See if you can find a way to further improve and shorten your code because of this. Improving/shortening code is a very important skill to learn when programming!