Digit al Makin g Pr ogr am m e Lesson 1: Basi c Funct i ons Sim - - PDF document

digit al makin g pr ogr am m e
SMART_READER_LITE
LIVE PREVIEW

Digit al Makin g Pr ogr am m e Lesson 1: Basi c Funct i ons Sim - - PDF document

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


slide-1
SLIDE 1

11/04/2017 1

Digit al Makin g Pr ogr am m e

Lesson 1: Basi c Funct i ons

Tool in Scratch Description of tool Tool in Microbit Description of tool To show words To show words To show a number To wait for 1 second To pause for 100 milliseconds To hide To clear the screen

Sim il ar ity Bet ween Scr act ch & Micr obit

slide-2
SLIDE 2

11/04/2017 2

Tool in Scratch Description of tool Tool in Microbit Description of tool To do an action forever To do an action forever To repeat an action for 10 times. You can specify the number of times you want the action to be repeated. To repeat an action for 4 times. You can specify the number of times you want the action to be repeated.

Sim il ar ity Bet ween Scr act ch & Micr obit

Tool in Scratch Description of tool Tool in Microbit Description of tool Setting a

  • condition. If this

happens, do this action. Setting a condition. If this happens, do this action. Setting a more complicated ‘if condition’. By clicking on the blue button, you can set more complicated ‘if condition’.

Sim il ar ity Bet ween Scr act ch & Micr obit

slide-3
SLIDE 3

11/04/2017 3

Tool in Scratch Description of tool Tool in Microbit Description of tool Specifying a variable Specifying a variable Setting the variable to a specified condition Setting the variable to a specified condition Used to pick a number randomly Used to pick a number randomly

Sim il ar ity Bet ween Scr act ch & 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

Som e Un ique Fun ct ion s I n Micr obit

slide-4
SLIDE 4

11/04/2017 4

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.

Exam pl e

Game Coding Description Make the worm appear randomly in any of the 5 holes for the user to hit.

  • 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

R ecal l … How do we use t he r an dom fun ct ion in Scr at ch?

slide-5
SLIDE 5

11/04/2017 5

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.

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.

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.

slide-6
SLIDE 6

11/04/2017 6

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

  • r 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?

slide-7
SLIDE 7

11/04/2017 7

Sol ut ion