11/04/2017 Digit al Makin g Pr ogr am m e Lesson 1: Basi c Funct i ons Sim il ar ity Bet ween Scr act ch & Micr obit Description of Description of Tool in Scratch Tool in Microbit tool tool To show words To show words To show a number To wait for 1 To pause for 100 second milliseconds To hide To clear the screen 1
11/04/2017 Sim il ar ity Bet ween Scr act ch & Micr obit Description of Tool in Scratch Description of tool Tool in Microbit tool To do an action To do an action forever forever To repeat an To repeat an action action for 4 times. for 10 times. You can specify You can specify the the number of number of times you times you want the want the action to action to be be repeated. repeated. Sim il ar ity Bet ween Scr act ch & Micr obit Description of Description of Tool in Scratch Tool in Microbit tool tool Setting a Setting a condition. condition. If this If this happens, do happens, do this this action. action. By clicking on the Setting a more blue button, you complicated ‘if can set more condition’. complicated ‘if condition’. 2
11/04/2017 Sim il ar ity Bet ween Scr act ch & Micr obit Description of Description of Tool in Scratch Tool in Microbit tool tool Specifying a Specifying a variable variable Setting the Setting the variable to a variable to a specified specified condition condition Used to pick a Used to pick a number number randomly randomly Som e Un ique Fun ct ion s I n Micr obit Tool Descriptions of tool To ‘draw’ an image Gives instructions on what to do when button A is pressed Can change to button A, button B, or button A and B Gives instructions on what to do when microbit is shaken 3
11/04/2017 Exam pl e Tools Description of tools The microbit will show - a smiley face, - wait for 200ms, - then show a sad face. This series of actions will repeat for 5 times when button A is pressed. R ecal l … How do we use t he r an dom fun ct ion in Scr at ch? Game Coding Description Create a new variable called “Place” Set this variable to pick a random number from 1 to 5 Set each number to a specific location Make the worm appear randomly in any of the 5 holes for the user to hit. 4
11/04/2017 How do we use t he r an dom fun ct ion in Micr obit ? If we want the Microbit to display some messages at random, this is how we can do it. Tools Description of tools When button B is pressed, the variable “Messages” will be set to pick either number 0 or 1. If number 0 is selected, the message “Hello!” will appear. If the number 1 is selected, the message “Bye!” will appear. CHALLENGE Usi ng t he t ool s t hat you have been i nt r oduced t oday, com e up wi t h a Sci ssor , Paper , St one gam e wi t h t he M i cr obi t . W hen shaken, show t he 3 pr eset i m ages of Sci ssor , Paper or St one r andom l y. W hen but t ons A and B ar e pr essed, cl ear t he scr een. 5
11/04/2017 CHALLENGE Af t er com pl et i on of wor k, Run, t hen com pi l e your wor k. Save as G am e_Your Nam e Save t hi s f i l e i n “ M y W or kspace” . Copy t hi s f i l e i nt o your M i cr obi t f ol der . Now, t r y your gam e! Does it wor k? 6
11/04/2017 Sol ut ion 7
Recommend
More recommend