Presentation is loading. Please wait.

Presentation is loading. Please wait.

Game Controller Lesson Three.

Similar presentations


Presentation on theme: "Game Controller Lesson Three."— Presentation transcript:

1 Game Controller Lesson Three

2 Buttons Button How it’s connected Joypad Up P8 Joypad Down P14
Joypad Left P12 Joypad Right P13 Fire SW 1 P15 Fire SW 2 P16

3 Lights 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

4 Turn Light 1 Red

5 1 Move Right Algorithm Algorithm
When the right button is pressed: move the light to the right Set CurrentPosition = 0 When the right button is pressed: Change the CurrentPosition by ? 1

6 Algorithms When the up button is pressed:
Change the CurrentPosition by ? Set the CurrentPosition light red Show the lights When the left button is pressed: Change the CurrentPosition by ? Set the CurrentPosition light red Show the lights When the right button is pressed: Change the CurrentPosition by ? Set the CurrentPosition light red Show the lights When the down button is pressed: Change the CurrentPosition by ? the CurrentPosition light red Show the lights

7 Algorithms When the up button is pressed:
Change the CurrentPosition by -8 Set the CurrentPosition light red Show the lights When the left button is pressed: Change the CurrentPosition by -1 Set the CurrentPosition light red Show the lights When the right button is pressed: Change the CurrentPosition by 1 Set the CurrentPosition light red Show the lights When the down button is pressed: Change the CurrentPosition by 8 the CurrentPosition light red Show the lights

8 New Algorithm When the right button is pressed Clear the CurrentPosition light Change the CurrentPosition by 1 Set the CurrentPosition light red Show the lights

9 Move Right

10 Latest Algorithm When the right button is pressed IF CurrentPosition + 1 is less than 63 THEN Clear the CurrentPosition light Change the CurrentPosition by 1 Set the CurrentPosition light red Show the lights END IF

11 Buzzzz When the right button is pressed IF CurrentPosition + 1 is greater than 63 THEN Clear the CurrentPosition light Change the CurrentPosition by 1 Set the CurrentPosition light red Show the lights ELSE Turn the motor on Pause for 1 second Turn the motor off END IF

12 Code

13 Code

14 Challenge Algorithm When the red light reaches the Ball
Set CurrentPosition to 0 Turn the CurrentPosition light red Set score to 0 Display the score on the micro:bit Set Ball to 10 Turn the Ball light blue Forever: When the red light reaches the Ball Change the score by 1 Set Ball to a random number between 0 and 63 Show the light


Download ppt "Game Controller Lesson Three."

Similar presentations


Ads by Google