Home  / Resources BBC micro:bit / Jump
 
Jump

Jump

Digital Technology  Computer Science  Robotics

  • Project 2: Jump
  • Student Ages: 09-14 years old
  • Activity Time: 60 minutes 
  • Activity Level: Beginner Coder

Prerequisites

Get Started

Learning Objectives

  • Create a multiplayer Kodu World using BBC micro:bit Player 1 and BBC micro:bit Player 2.

Contents

Student Activities

To create a Multiplayer Kodu world using tiles specific the BBC micro:bit, make sure you connect two (2) micro:bit devices and install the mbed serial port driver

Welcome! This activity will teach you how to construct a competitive jumping game to squash an opponent. Let's get started!

Steps

Step 1: Add Objects

Start Kodu Game Lab. Select the New World option from the Main Menu, and Kodu Game Lab will open and display a patch of ground directly in the center of the screen.

Select the Object tool (the Kodu icon on the toolbar). With a game controller, select the Object tool using the left thumbstick. 

  • For mouse users, move the mouse pointer to the center of the terrain and click and release the left mouse, which open the pie menu. Use your mouse to select two Kodu objects or another two moving objects (except Rover). 
  • For game controller users, move the camera to the center of the terrain and press the A button, which open the pie menu. Use the game controller to select the object. Use your game controller to select two Kodu objects or another two moving objects (except Rover). After adding two moving objects to the terrain, press button B for the Tool Menu.    

Finally, you want to create a nonmoving object, such as a Rock, by following the same process.


Add Objects

Step 2: Program Player 1 - Move

You want to move Player 1 using the BBC micro:bit.

  • Using a mouse, select the Object tool and right-click the mouse on the object, Kodu. Select the Program option for Kodu. Select the When box with left-click of the mouse. 
  • Using a game controller, use the Object tool and move the control circle over the object and press Y button. Press the A button on the When box.

Select the BBC micro:bit and tilt programming tiles. Select the Do box and select move. Kodu uses the accelerometer on the BBC micro:bit. The accelerometer detects movement on the BBC micro:bit with tilt. The accelerometer detects changes in the micro:bit’s speed and detects a standard action such as tilt. You use tilt to register an event that will run when a tilt event happens.

Alternatively, Kodu can use the L-stick on the Wired Controller or Keyboard WASD to move.

Tilt

  • Play Game to see if the code works as expected.
    • Using a keyboard/mouse, press Esc key twice. The first Esc press will close the Programming window and the second Esc will Run the program (return to edit mode by pressing Esc).
    • Using a game controller, press button B. Then press button B to select Play Game (return to edit mode by pressing Back button). 
  • Move the BBC micro:bit in any direction to observe the tilt event in action. 
  • Notice the yellow light on the back of the micro:bit continuously flash yellow when the mbed serial port driver installation has been successful. The yellow light is the status LED. It will continuously flash yellow when the system is telling the user that something is happening.

Step 3: Program Player 1 - Jump

How about using the BBC micro:bit buttons? Let's Program Player 1 to jump with button pressed. When BBC micro:bit A button is pressed, Player 1 jumps very high. Select the new When box in Row 2, then select BBC micro:bit and A button. Select the Do box and select jump and add high three times. You register an event handler that executes whenever an input button (A) is pressed during program execution.    

Alternatively, Kodu can use the Button A on the Wired Controller or Space Key to jump.

Button A

  • Play Game to see if the code works as expected.

Step 4: Program Player 1 - Squash 

Let's add code to be squashed when bumped above!
Squash Player 1

Step 5: Program Player 2 - Move

Let's add code to move Player 2 using micro:bit tilt.

Alternatively, Kodu can use the L-stick on the Wired Controller or Keyboard Keys Up/Down/Lt/Rt to move.


Player 2

  • Play Game to see if the code works as expected.


Step 6: Program Player 2 - Jump

You want to give Player 2 that ability to jump. Let's add code that will run when button A is pressed! You want Player 2 to jump very high when button A is pressed. 

Alternatively, Kodu can use the Button A on the Wired Controller or Mouse left-click to jump.


Button A

  • Play Game to see if the code works as expected.

Step 7: Program Player 2 - Squash

Let's add code to be squashed when bumped above!  


Squash Player 1

  • Play Game to see if the code works as expected.

Step 8: Program Rock -  Switch Page 2

You want to allow continuous gameplay between Player 1 and Player 2 with pages. So you will need to add a new page. Pages are found at the very top of the screen. Using the Pages tool, you can change behaviors and create new scenes. Let's program the nonmoving object, such as a rock. The nonmoving object will always see when a Player is squashed. When Player is squashed, then the game will switch from Page 1 to Page 2! You need to tell Page 1 to move to Page 2, which ensures the game is affected by the programming on Page 2. 


Page 1

Step 9: Program Rock - Page 2

You will switch from Page 1 to Page 2! Once your pencil moves to the Pages tool, you can click the left or right buttons with the mouse or use the left or right buttons on the D-Pad to move between pages. Try to move to Page 2. When you switch to Page 2, notice that it's completely blank.


  Page 2

Step 10: Program Rock (Page 2)- Timer 

You want to add a timer that will count up in 2-second increments.


Timer

Step 11: Program Rock (Page 2) - Row 2

You want to tuck programming Row 2 underneath 1 so any programming placed in 2 is always being checked for a condition that will trigger the action. Row 2 moves to the right and is a child of 1.

  • Using a mouse, click the 2 and hold down the mouse button while dragging to the right. When row 2 is underneath 1, release the right-click.
  • Using a game controller, hover over 2, then press Button A to move row 2. When row 2 is underneath 1, press Button A.

Child

Step 12: Program Rock (Page 2) - Heal it

When a Player squashed another Player, you want the Player to recover from damage. You want the rock to see a squashed Player and heal the Player by 100 points, which makes the Player recover. 


Heal

Step 13: Program Rock (Page 2) - Switch Page 1

You want the Player to remain squashed for 2 seconds before the Player appears. You want to stay on Page 2 for 2 seconds before returning to Page 1. After 2 seconds is over, you want to swing to Page 1.


Switch to Page 1

  • Play Game to see if the code works as expected.
  • When a Player is squashed, after 2 seconds, the squashed Player is healed and appears.

Step 14: Save World

You want to save your work. The Game Save Screen is useful in managing the game development. You go to Home Menu then select Save my world. You want to type the game name in the Name field and describe the gameplay as well as rules of the game in the Description, then click or press Save. Finally, you want to select Change World Settings, scroll down to Start Game With, and select Description with Countdown.


Launch

  • Play Game to see if the directions appear as expected.


Play Game

Skills

Character

Citizenship

Collaboration

Communication

Creativity

Critical Thinking

Project Based Learning