O'Reilly logo

Raspberry Pi Projects for Kids by Daniel Bates

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Moving the character

Now, let's start adding some code and making the game interactive! In this section, we'll do everything necessary to launch our main character using the slingshot.

Initialization

The first thing we want to do is make sure the position of our main character resets every time we start the game. Click on the main character and create the following script in the script area:

Initialization

The code snippet states that when the green flag is clicked, the current sprite (the main character) will move to the same position as the slingshot.

Test that your code works by clicking on the green flag. You should see your character jumping to the same position ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required