CL5 - CH6 - AI Space Battle Game
CL5 - CH6 - AI Space Battle Game
SESSION 6
In this activity, we will make a gesture-controlled space battle game using Artificial Intelligence, in
PictoBlox and control the Rocketship game made in session 4 using the tip of our fingers.
MATERIALS REQUIRED
□ Computer / Tab / Laptop with PictoBlox Installed.
STEP-BY-STEP
1. Open the PictoBlox file “Space Battle Game”, we made in the session 4.
2. Now, all the scripts will remain the same except the script of the Rocketship. We will modify the script
of Rocketship, to change our controls. Let us start!
3. Delete the if blocks for left and right arrow keys from the main script.
Remove
these 2
if blocks
4. Add the Human Body Detection Extension to your palette, like we did in the previous session.
5. Add a turn-on video on stage with a 0% transparency block from the Human Body Detection palette
below the when green flag clicked block. Make the transparency 50%.
6. Now, as we need the details of our hand in real-time, we will be using analyse image for hand from
camera block from the Human Body Detection palette inside the forever block.
7. Next, we need to check whether our hand is detected or not. Thus, place an if () then block from
the Controls palette, below the if () then block
already present.
8. Add is hand detected block inside the if () then
block.
9. Add set x to () block from the Motion palette
within the if () then block, we just added.
10. Next, place the x position of () block from
the Human Body Detection palette into the set
x to () block, and select top of index finger from
the dropdown.
11. Add set y to () block and set the value inside it
to -140.
12. Hurray… Our game is finally ready! Click the
green flag and play!