Lesson 1 of 0
In Progress

Session 6: AI Space Battle Game

Introduction

We have created the Space Battle game in the past sessions. How about modifying that game such that, you can control the Rocketship using your fingertips? Sounds pretty cool, right?

In this lesson, we will make a gesture-controlled space battle game in PictoBlox and control it using the tip of our fingers.

Coding

We will begin the project with the same file we had created in Space Battle game.

All the scripts will remain the same except the script of the Rocketship. We will modify this script to change our controls:

Let’s start.

  1. Open the PictoBlox file of Space Battle Game, that we made in the previous sessions.
  2. Delete the control blocks for left and right arrow keys from the main script of the Rocketship sprite. The script should look like the one shown below:
  3. Add the Human Body Detection Extension.
  4. 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%.
  5. Now as we need the details of the 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.
  6. 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.
  7. Add is hand detected block inside the if-condition of the if () then block.
  8. Add set x to () block from the Motion palette within the if () then block, we just added.
  9. 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.
  10. Add set y to () block and set the value inside it to -140.
  11. Don’t forget to save your script by the name AI Space Battle Game.
  12. Yayy! The script is complete. Run the project, play, and have fun!

Assignment

Before moving on to the next lesson, a small assignment awaits you!

You must upload the PictoBlox program you created in this activity to the website. Submitting the assignment is a must in order to receive the certificate after completing the course.

Follow the steps below to upload your assignment:

  1. Click on Browse.
  2. Search and Select your saved Project file(.sb3) and Click Open.
  3. Click on Upload to submit the assignment.
evive Alert
The file type allowed is the sb3 file, generated from the PictoBlox program. The maximum file size allowed is 5 MB.

Good luck!