Let’s Fight! Warrior!

Here, PiSloth is a brave warrior, when it appears in front of the enemy, it will let out a roar and rush to the enemy.

../_images/warrir.jpg

Note

You can download and print the PDF Cartoon Mask for your PiSloth.

TIPS

You may want to simplify your program with Variable. For example, when you have multiple functions that need to read the obstacle distance, you don’t need to read the value for each function, just load the value into a variable and use it multiple times.

../_images/sp210512_114830.png

Click the Create variable button on the Variables category to create a variable named distance.

../_images/sp210512_114916.png

You can use this block to set up an endless loop.

../_images/fight1.png

This is a block that jumps out of the loop, and it has two options and can be only used within a loop.

  • break out: Jump out of the entire loop.

  • continue with next interation: Jump out of the current loop and enter the next loop.

../_images/fight2.png

EXAMPLE

Note

  • You can write the program according to the following picture, please refer to the tutorial: How to Create a New Project?

  • Or find the code with the same name on the Examples page of the EzBlock Studio and click Run or Edit directly.

After the code is run, PiSloth will continuously detect the distance of the obstacle, when the distance is between 5 and 40, PiSloth will make a roaring sound and rush forward; when the distance of the obstacle is less than 5, PiSloth will stop.

../_images/fight.png

Flow Chart

../_images/flowchart_fight.png