# 2 player pong quiz

a two-player game of Pong using TWO BBC micro:bits! #LED #number #math #acceleration #docs

## Name

## Directions

Use this activity document to guide your work in the [2 player pong tutorial](/microbit/lessons/2-player-pong/tutorial)

Answer the questions while completing the tutorial. Pay attention to the dialogues!

## 1. Write the two global variables that record if the player has the ball and if the game is running, and assign these variables to their initial values.

<br/>

<br/>

## 2. Write the global variable that keeps track of the game state in which whoever presses button A first will get to start the ball. Assign this variable to its initial value.

<br/>

## 3. Write the code that creates a condition to know when Button A is pressed. Then write the 'If statement' to ensure that 'claim ball' is true. If the 'claim ball' is true, then write the code that sets P0 to 1 to signal to the other device that the player has claimed the ball.

<br/>

<br/>

<br/>

<br/>

## 4. Write the code to move the paddle right when button B is pressed. Be sure to check if the game is running and if the paddle is not already on the rightmost edge. 

<br/>

<br/>

<br/>

<br/>

## 5. What are the three pieces of information that we send to the other device when transferring the ball? (Hint: look in your "transfer ball" function, and look for any places that contain "transfer byte").

<br/>

<br/>

## 6. Using the function "read velocity", write the code that reads the x-coordinate and the x-velocity of the ball. (Hint: look at the function "read ball".)

<br/>

<br/>

<br/>

## 7. Write the code that updates 'ball x velocity'. (Hint: look at the "update velocity" function.)

<br/>

<br/>

## 8. Write the code to move the ball. To move the ball, unplot the ball's original position, update its position variables, and then plot the ball's new position.

<br/>

<br/>

<br/>

