Select “Spaceship” from the “Space” theme.We have 3 distinct sprites or objects in this game: Then select Choose new sprite from library for each of our new sprites. Select “space” from the “Space” category. Stage/Backdropįor the Stage, go to Choose backdrop from library. We needed to set a backdrop and create the necessary sprites and objects. When the fish sprite broadcasts the message Eat, we want the shark sprite to make a sound and to look as if it has eaten the fish.We wanted the player to drive a rocket in space and fight giant alien octopuses for this game. Therefore, drag and drop the delete this clone block. As soon as the shark touches the clone, it should disappear.A dialogue box will appear asking you to enter the message type Eat. From the drop-down of the broadcast () block, select New message.Drag and drop the broadcast () block from the Events palette below the change () by () block. Next, we will send a message to shark sprite so that the shark can perform certain actions accordingly.touches its clone, drag and drop the change () by () block from the Variables palette inside the forever block and from the drop-down, select Score. To increase the Score by 1 every time the shark ‘eats’ a fish i.e.To sense the shark, drag and drop the touching () ? block from the sensing palette inside the C shape of the if block.Drag and drop an if block inside forever block.Drag and drop the when I started as a clone block in the scripting area.Follow the steps below for the script to check if the shark eats one and increase the score accordingly: Hence, we will end the script using the delete this clone block from the Control palette.Įvery time the shark eats a fish, the S core should increase. After moving from one point to another the clone should disappear.Select random position from the drop-down and set value of seconds as 2. To make the clones move from one position to another, we will use the glide () secs to () block.Drag and drop the show block from the Looks palette below the go to () block.To make the clones appear at random points on the Stage, drag and drop the go to () block from the Motion palette below the when I start as a clone block and select random position from the drop-down.Drag and drop the when I start as a clone block from the Control palette.To make sure there is a gap between the appearance of two clones, we will add a delay of 1 second using the wait () seconds block.Hence, we will add the next costume block from the Looks palette. We also want every clone to look a little different.Therefore, we will map the potentiometer values using the following mathematical formula:Ĭloning is done to reduce the number of sprites and scripts needed in a project, and therefore preventing unnecessary lag. We want to control the direction of the shark using the potentiometer, but here is a catch: the potentiometer gives values in the range of 0 to 1023 and our shark can rotate only 360 °.Drag and drop the point in direction () and move () steps blocks inside the forever block.Therefore, drag and drop the forever block from the Control palette. Whatever we write next must execute continuously.Drag and drop the set my variable to () block below the go to x () y () block and select Score from its drop-down set its value as 0.For that, go to the Variables palette and click on Make a Variable a dialogue box will appear. We will make a variable to keep track of the number of fish the shark eats.To set initial position, drag and drop the go to x () y () block and set x and y to 0 this will set the center of the Stage as the shark’s initial position.Drag and drop the set size to () % block from the Looks palette to adjust the shark’s size.Drag and drop the when flag clicked block to scripting area from the Events palette.Then, choose it as your board and select the appropriate port from the Connect menu. Connect evive to your computer and open PictoBlox.Step 3: Assigning Movements to Sharkįollow the steps below to write the script: Open the sprite library as we did in the previous chapter and choose the fish and Shark2 sprites. In this shark eating game, we need two sprites: the shark and the fish. Therefore, choose any of the underwater backdrops from PictoBlox’s backdrop library. Since we have a shark and a lot of fish in our game, our background should be a suitable environment for them. Building Guide Step 1: Setting Up the Stage