Skip to content

Gweithgaredd

Carreg, papur, siswrn

Dechreuwr | MakeCode, Python | Dangosydd LED, Mesurydd cyflymiad | Ar hap, Dewis

Cam 1: Gwneud

Beth yw e?

Chwarae'r gêm glasurol hon â dau micro:bit a dysgu am ddewis, newidynnau a rhifau ar hap ar yr un pryd.

Mae'r ddau fideo hyn yn dangos i chi yr hyn y byddwch yn ei greu a sut i'w godio:

Cyflwyniad

Canllaw codio

Sut mae'n gweithio

  • Mae carreg, papur, siswrn yn gêm hapchwarae glasurol ar gyfer dau. You and a partner shake your fists 3 times and then make gestures at random to show a rock, paper or scissors. Rock beats scissors, scissors beat paper and paper beats rock (it wraps the rock!).
  • When the micro:bit accelerometer detects a shake movement, it sets the variable tool to a random number: 0, 1 or 2.
  • We use 0 because computers start counting at 0, and it’s good to remember that 0 is a number!
  • The program uses selection to decide what image to show on the LED display. If the random number was 0, it shows a rock icon, if it was 1 it shows the icon representing paper. If it wasn’t 0 or 1, it must be 2 because we instructed the micro:bit to only pick random numbers between 0 and 2, so in that case it shows scissors.

Beth sydd ei angen arnoch

  • 2 micro:bit (neu efelychwr MakeCode)
  • Golygydd MakeCode neu Python
  • pecynnau batri (opsiynol)
  • a partner to play with

Cam 2: Codio

Cam 3: Gwella

  • Draw your own icons for rock, paper, scissors.
  • Think of other tools that could replace rock, paper and scissors or invent new rules.
  • Use the micro:bit radio function to make a game that knows if you won or lost by communicating with your friend’s micro:bit.
Ariennir gan Lywodraeth Cymru / Funded by Welsh Government

Translation generously supported by the Welsh Government.