Introduction to Programming

Activity: Make Tobi Walk

Lesson 1: Introduction

Let's Code

Follow the steps below:

  • Create a New file in PictoBlox.
  • If you are working on Windows, macOS, or Linux:
  • Open PictoBlox and create a new file
PictoBlox interface showing the File menu open to create a new file
  • Select the coding environment as Block Coding.
PictoBlox Select your Coding Environment dialog showing Block Coding and Python Coding options
  • Follow the step if you are working on Android or iPhone:
  • Open PictoBlox App and select My Space Tab from the home screen
PictoBlox App home screen showing My Space Tab to create a new file on mobile
  • Click on + sign to create a new file.
PictoBlox stage showing Tobi the bear sprite added to the project with the scripting area visible
  • A new file should be created like this
PictoBlox scripting area showing the when flag clicked hat block added from the Events palette
  • Open the Events palette and drag and drop the when flag clicked block into the scripting area. The when flag clicked block is a special type of block called hat block. It is used to start a script. Using this particular hat block you can run the script by clicking on the green flag above the stage.
PictoBlox scripting area showing the forever block from the Control palette added below the when flag clicked block
  • Next, open the Control palette and drag and drop the forever block below the when flag clicked block.
PictoBlox scripting area showing the move 10 steps block from the Motion palette added inside the forever block
  • This block is used when you want a set of blocks to keep running until the script is stopped manually.
PictoBlox scripting area showing the wait 0.1 seconds block from the Control palette added below the move steps block
  • Then, open the Motion palette and drag and drop the move () steps block inside the forever block.
PictoBlox scripting area showing the if on edge bounce block from the Motion palette added inside the forever block
  • This block is used to move the sprite by a specified number of steps. In our case, it is 10.
PictoBlox scripting area showing the set rotation style left-right block added below the when flag clicked block
  • Next, open the Control palette and drag and drop the wait () seconds block below the move () steps block and change the delay value to 0.1 seconds. The wait block is used to pause/delay the script execution by the specified time.
PictoBlox completed script showing all blocks assembled: when flag clicked, set rotation style, forever loop with move steps, wait, and if on edge bounce
  • Run the script by clicking the green flag. What just happened? Where did Tobi go?! As it seems, he went out of the frame. Let's fix this so that Tobi doesn't wander off again.
  • Open the Motion palette and drag and drop the if on edge, bounce block inside the forever block.
PictoBlox stage showing Tobi the bear walking back and forth on a green outdoor background after running the completed script
  • This block detects whether the sprite has touched the edge of the stage or not and changes the direction if it has.
PictoBlox stage showing Tobi the bear walking back and forth on a green outdoor background after running the completed script
  • Run the script by clicking the green flag. What is happening to Tobi now? Is he upside-down? To stop this, you must change the rotation style.
  • Go to the Motion palette and drag and drop the set rotation style () block below the when flag clicked block and select left-right from the drop-down.
PictoBlox stage showing Tobi the bear walking back and forth on a green outdoor background after running the completed script
  • The script is now complete! Run it by clicking the green flag.
PictoBlox stage showing Tobi the bear walking back and forth on a green outdoor background after running the completed script
  • Yay! You've just completed your first script! Pat yourself on the back.
PictoBlox stage showing Tobi the bear walking back and forth on a green outdoor background after running the completed script

Saving The Program

  • To save the program, click on File > Save As.
PictoBlox stage showing Tobi the bear walking back and forth on a green outdoor background after running the completed script
  • A window will popup. Choose the location as Desktop or any other relevant folder. Name the file Tobi Walking.
PictoBlox stage showing Tobi the bear walking back and forth on a green outdoor background after running the completed script
  • Click on Save.

Subscribe to our newsletter.

Get updates to news and events.