1 of 30

Upper Elementary

Computer Science

Click-a-Martian

2 of 30

Step-by-Step

Go to Clever. Login with your school email.

Open Code HS

Select the : Click and Martian Project

3 of 30

Objective

Students will be able to create an interactive Whack-a-Mole style game using conditionals, variables, booleans, and events.

4 of 30

Sample Project

5 of 30

Vocabulary

Conditional: A command that tells a program how to make a decision if something is true or false

?

6 of 30

Vocabulary

Variable: A container that can hold one value at a time

7 of 30

Vocabulary

Boolean: A value that can only be true or false

8 of 30

The "if/then" block is a way to make your sprite do something only if a certain condition is met. It's giving instructions: "If something is true, do this; otherwise, don't do anything."

In the program, the “if/then” block will be used to determine which Hole the Mole is going to.

9 of 30

“Operator” blocks are blocks that can complete math problems. The “comparison operator” blocks compare two values.

In the program, the “booleans” will tell the Mole what hole to go to and compare the score.

10 of 30

The “variables” blocks are like a box or a container that holds the value for the things in the program. A variable can only hold one value at a time, but that value can change over time.

In the program, the “score” and “hole” variable will be used to set the score and determine the hole the Mole is going to.

11 of 30

Starter Code

The parts of a program that are created for you are called Starter Code. We provided the backdrops and the mole sprite for you!

12 of 30

Make a prediction!

  • Have you seen this game before?

  • What code will you need?

13 of 30

When Flag Clicked

This event resets the score.

Mars

14 of 30

When Sprite Clicked

This event changes the score

15 of 30

Begin programming the Mole to set up the game and create a Score variable.

Mars

0

16 of 30

Program the Mole to continue until a certain score is met, and create a Hole variable.

Repeat until the score is greater than 15. Or Pick your own score to win!

Mars

17 of 30

Add a conditional in the repeat to show something happen if the Mole is touching Hole 1.

Matches the holes location on the stage.

Time until the mole hides.

Mars

18 of 30

Embed an if/then inside the repeat until to show something happen if the Mole is touching Hole 2.

Matches the holes location on the stage.

Time until the mole hides.

Mars

1

1

19 of 30

Now it’s your turn!

  • Follow the same process to program Hole 3 and 4.
    • The location should match where the hole is on the stage.
    • Each wait time should be different.

Add a switch background to show you win when you reach above 10

20 of 30

Holes 3 and 4

21 of 30

Explain your code.

  • Add comments to tell what each part of the code does.

  • Edit numbers in the wait blocks.
    • What happens to the Mole?

1

22 of 30

Now it’s your turn!

  • When the mole is clicked, the costume should switch and a sound should play to indicate the mole has been clicked.

  • The player should score 1 point for clicking the mole.

  • Then add

23 of 30

As you program, check for bugs!

  • As you work, make sure your event blocks and animations are working properly.
  • If you find a bug or an error, debug or fix it as you go!

24 of 30

Explore your game!

  • Click the green flag.
  • Click the moles as they appear.
  • Can you score 10 to end the game?

25 of 30

Are you ready for more?

Customize your game by adding on!

  • Add another hole to the game.
  • Add a sound when you win the game!
  • Create A timer countdown.

26 of 30

Option: Customize your background

  1. Click Stage
  2. Click Backdrop
  3. Rename it Mars
  4. Use the tools to draw a mars like background.
  5. Keep the holes in the same place.

27 of 30

Option: Customize your Sprite to make a Martian.

  • Click Choose a sprite
  • Choose an alien like creature.
  • Delete all but it’s head
  • Customize the colors
  • Resize the sprite to fit on the holes.

28 of 30

Reflection

How are the “Hole” and “Score” variables different?

Why isn’t the Hole variable visible on the stage?

29 of 30

Marshmallows for Martians

30 of 30

There was an Old Martian Who Swallowed the Moon