How To Create A Cozmo Mobile Game In Scratch

How To Create A Cozmo Mobile Game In Scratch [Step By Step Guide]

By Arun Gupta

Scratch has emerged as one of the best platforms for kids to explore while learning computer programming. 

The platform, developed at the Massachusetts Institute of Technology in 2003 and released in 2017, provides a high-level block-based programming language. 

Because it is block-based, meaning that codes are already embedded in the blocks, children do not perceive it as complex; rather, it makes learning to code more fun and interesting.

Scratch allows children to create a variety of games, animations, and simple applications. In this blog, we will discuss one such type of game that is simple to create while also being fun and interesting to play, the Cozmo Mobile Game.

Scratch allows kids to create a variety of games, animations, and applications. In this blog, we discuss how to create a Cozmo Mobile Game

Creating this game will help you to understand how we can play scratch games on mobile. 

Create a Cozmo Mobile Game in Scratch – Step by Step guide

Let’s start with the Cozmo mobile game’s journey.

Before you start to create the game make sure that you are logged in and to log in you must be a registered Scratch user. If you already have an account, that’s great, but if not, you can create one by clicking on join scratch. 

Follow the steps below to start creating!

STEP 1: Go to the scratch menu and select Create.

How To Create A Cozmo Mobile Game In Scratch
How To Create A Cozmo Mobile Game In Scratch

STEP 2: Firstly, select your first sprite. Go to the right bottom corner of the editing project page and select a sprite. There are numerous sprites available for us to choose from.

How To Create A Cozmo Mobile Game In Scratch
How To Create A Cozmo Mobile Game In Scratch

We will also need an appealing background. We must return to the right bottom corner and select a backdrop. Choose a background based on your preferences.

How To Create A Cozmo Mobile Game In Scratch
Without Backdrop
How To Create A Cozmo Mobile Game In Scratch
With Backdrop

Now that we’ve completed the design, it’s time to write the code for our sprite (car). Similarly, we will select one more sprite as a block that will provide us with a score when we collect it. Adjust the sprite’s size based on the sprite’s compatibility with the screen.

How To Create A Cozmo Mobile Game In Scratch

If we want to upload our own sprite, Scratch also allows that. 

Now it’s time to upload our new sprites, such as a button that will cause our sprite to move around when clicked. We use the same procedure mentioned above to select the sprites.

How To Create A Cozmo Mobile Game In Scratch

We must rename all of the buttons as Up, Down, Left, and Right, and arrange them accordingly.

STEP 3: To make our car move in all directions (Up, Down, Left, Right), we will use the event block in the coding section and create an event for our buttons, which we have already selected. Go to the event in coding, click on it, and then select the green flag that was clicked. We will apply conditions that will allow the buttons to be clicked from a phone or a computer.

  1. Choose the green flag code from the event block. 
  2. Take out forever block from control. 
  3. Now take if block from control and put it inside the forever to make the condition to run continuously. 
  4. We go to the operator, pick it out the logic block, and put it in the if block. 
  5. Now we will choose touching mouse pointer and mouse down (for playing from mobile click) for sensing. 
  6. Choose a broadcast message from the event block make the new message (any) “up” for making your up button to work. 
How To Create A Cozmo Mobile Game In Scratch

STEP 4: It’s now time to do codes for the car to receive the broadcasted signals and move around the stage.

Please ensure that you have chosen the correct sprite. 

  1. Go to the event block and select ‘When I Receive,’ as we will for all other buttons (Up, Down, Right, Left).
  2. Go to motion and pick a point in direction 90 to make your cozmo move perfectly. 
    • For Up, the point in direction will be 0 
    • For Down, the point in direction will be 180 
    • For Left, the point in direction will be -90 and for Right, it will be 90. 
  1. Choose the move block from the motion to allow our Cozme (sprite) to move as instructed. 
  2. The number of move steps will be +ve for ‘up,’ ‘down,’ ‘right,’ and ‘left.’ You can use the following images as a guide.
How To Create A Cozmo Mobile Game In Scratch

Similarly, we write code for when the arrow keys on our keyboard are pressed. Take when key pressed from the event block for all buttons and choose broadcast message as any arrow keys pressed for this. For a better understanding, look at the images below.

How To Create A Cozmo Mobile Game In Scratch

STEP 5: Now we’ll make our block sprite move to a random position when our car (cozmo) hits it, and we’ll calculate the score.

  1. Choose your block sprite and, in the script area, select when the green flag is clicked from the event.
  2. We’ll make a ‘SCORE’ variable from the variable block and set it to 0 before placing it below the green flag.
  3. Now, from the control panel, select the forever block.
  4. Move the If block to the forever block from control once more.
  5. Now apply the condition if car (sprite name) touches take touching sprite block from sensing. 
  6. Take the change score by 1 from the variable block. 
  7. Go to the motion and insert the go to random position block inside the if block.
  8. This step is an extra feature to add sound for collecting the score, choose it from sound block pick play sound. 

All of the above steps are shown below in the picture.

How To Create A Cozmo Mobile Game In Scratch

STEP 6: Now we must execute the code for backdrop go, select the stage, select a new backdrop, and write ‘game over‘ on it. This will help us in displaying the message game over.

How To Create A Cozmo Mobile Game In Scratch
  1. Now we have to create a variable named it as timer from the variable. 
  2. Back to the code area and choose again the green flag clicked for backdrop because we need to start the game with the first backdrop and take the switch backdrop block from looks. 
  3. Choose the set timer variable to 30 sec.
How To Create A Cozmo Mobile Game In Scratch
  1. Next, we need to repeat the timer until it reaches 0. For this take out repeat until block from control. Go to the operator block choose and put it in repeat until.
  2. Here we are setting the timer to 0 so we will take the timer from the variable. As the timer reaches 0 the game will stop and the backdrop will switch to the game over backdrop
  3. Choose wait 1 second from control and choose change timer by -1 from variable put it in repeat until block. 
  4. Now choose switch backdrop to game over and put it outside of repeat until block. 

All codes are shown below in the picture. 

How To Create A Cozmo Mobile Game In Scratch

Congratulations, our Cozmo mobile game is complete. In this game, you can change your sprites to your liking.

Conclusion

The capabilities of the scratch platform and programming language do not stop here. Scratch also allows you to create a plethora of other games and projects. 

The creation of each project on Scratch leads to the unraveling and learning of computer programming fundamentals. It’s also a fantastic way to bring your imagination and creative ideas to life.

BrightChamps Book Free Trial

Learn Scratch at BrightChamps with its specially designed curriculum that makes learning programming easy for students in Grade 1-12.

BrightChamps also teaches a variety of other programs that help kids build a foundation in computer programming through activities, interactive lessons, and other means.

Arun Gupta

⭐⭐⭐⭐⭐

I am a child psychologist as well as a teacher, and I love what I do. My strongest skill is observation, and I enjoy developing new ideas into apps. My goal at BrightChamps is to help children improve their IT skills in order to better prepare them for the future. Learn from Me

Categories

Learn Scratch Animation

Become A Certified Scratch Game Developer for FREE!

100% Risk-Free. No Credit Card Required

Get Scratch Certified

Related Articles

Trending Articles

Free Coding Resources

Free Kids Coding Resources📕

Receive a copy of our Top 10 FREE Resources for your Kids

Success! 🎉

Share This