Student Login

Coding Activity #6

Can you drive a spaceship from one portal to another without getting hit by a comet?

Activity #6 - Comet Scanner

In this activity, you will drive a spaceship from one portal to another. However, when you run the program, 3 comets randomly generate somewhere in the night sky. Unless you’re really lucky, your ship is going to hit the comets without even knowing where they are – we’ve got lives at stake!

  • Ontario curriculum alignment:  Grade 8
  • Best for:  Intermediate coders of all grade levels!

Before you begin ...

This hands-on activity uses a free coding platform called "Scratch". Please make sure you've watched our "Introduction to Scratch" video, and that you're signed into your Scratch account. If you need help, click below. Otherwise, skip down to STEP 1 to get started!

Open the Scratch activity

Click the button below to open the activity. It will open in a new window/tab which allows you to keep this page open at the same time and easily switch between tabs while you work through this activity.

  • After you open the activity, click on the blue "See inside" button to access the activity.
  • If you are logged into your Scratch account, then you can click on the green "Remix" button to save this activity to your personal Scratch account so you can save your work and also share it with others!
Open the activity

Watch this video

Get your spaceship from one portal to another

Level 1

In this level, we will drive a spaceship from one portal to another. However, when you run the program, 3 comets randomly generate somewhere in the night sky! Unless you’re really lucky, your ship is going to hit the comets without even knowing where they are – we’ve got lives at stake!

Here’s your challenge: create a scanner – a program the scans the night sky, looking for comet sprites, telling us where they are.

Your Task

Your challenge is to “call upon” already created functions within the code in a logical sequence to make the comet scanner work as it should. Your first task is to create a program starting at the top left of the stage that goes all the way to the right, one square at a time, scanning for where the comets are.

Using these sections of code, edit the code and use the spacebar key on your keyboard to activate the comet scanner. Good luck!

When you’ve completed this level, watch the next video below for the next level.

Watch this video

Scanning for comets

Level 2

When you press the spacebar on your keyboard, your purple scanner scans all the way to the left while repeating the movements 24 times.

Your next task is: every single time your purple scanner block moves, you are checking if there is a comet in that position.

Using these sections of code, use the right blocks of code to help check if the comets are in that position. Good luck!

When you’ve completed this level, watch the next video below.

Watch this video

Expanding your comet scanner

Level 3

When you press the spacebar on your keyboard, your purple scanner scans all the way to the left while checking if there is a comet in each space it scanned. Although you may not see a red comet yet, as the scanner goes further down the stage, you will see the comet appear!

Your next task is: now that the purple scanner is at the end of the row, code the scanner to move down one space – to the next row – and continue scanning the rest of the stage area.

Using these sections of code, use the right blocks of code to move down one row and continue scanning. Good luck!

When you’ve completed this level, watch the next video below.

Watch this video

Getting your scanner to scan the entire area

Level 4

When you press the spacebar on your keyboard, your purple scanner scans all the way to the left, checks if there is a comet in each space it scanned and moves down one row. Great!

Your next and final task is: now this whole sequence of steps – that’s already repeating – needs to repeat 24 times. That will allow your scanner to scan the next 24 rows successfully and efficiently on the stage.

Using these sections of code, use the right blocks of code to continue scanning the remaining rows. Good luck!

When you’ve completed this level, watch the next video below.

Watch this video

Can you move your spaceship to the end portal?

Congratulations!
Your comet scanner is functioning as it should, and it also displays where all the comets are. Now that you know where all the comets are located after the scan is complete, use the left, right, up, and down arrow keys on your keyboard to move your spaceship to the end portal successfully.

Bonus Challenges - Try Them!

  1. For a harder challenge, press the ‘C’ button on the keyboard to add more comets in space. Press the ‘R’ button on the keyboard to reset the number of comets in space.
  2. Program your purple comet scanner to scan from the bottom up.
  3. Challenge a friend to navigate through space and the hidden comets with or without scanning in space.

#207 - 8501 - 162nd Street
Surrey, British Columbia
Canada  V4N 1B2

Parents

Learn More
Book Samples
Online Platform
Pricing
Online Store
Free Trial

Teachers

Learn More
Book Samples
Teacher Resources
School Pricing

About

About Us
Contact
Privacy Policy
Cookie Policy
Terms & Conditions