Code a Dice to Roll
This challenge has been written by Fabrizia Agnello and is part of the EU CODE WEEK CHALLENGES.
Target Audience
  1. Teachers and educators
  2. Primary School students (6 to 12 years)
  3. Lower Secondary School students (12 to 16 years)
  1. Beginner
  1. 1 hour
  1. To enhance creativity in coding.
  2. To code a simulation of a randomly moving object to be used if the real object is not available
Recommended Materials
  1. Scratch
In this challenge you will code a dice to randomly roll on your command. You can choose any type of dice with the number of faces you like, as those used in role play games, and add sounds as well.
  • Log in to Scratch
  • Choose a backdrop
  • Create your dice sprite or search for one on the web and upload it to your program
  • Create as many costumes for the sprite as the number of faces of the chosen dice, each of them showing a different number
  • Choose how you want the dice to start rolling (pressing a keyboard key, clicking on the sprite, etc.) and write the code
  • Code the sprite to randomly change costume at the end of the roll
  • Add sound effects
Share the link to your work in your Instagram Bio: tap the Edit Profile button on your Instagram and add the link to your work in the Website field. After that, create a new post, add a screenshot of your work, write “Link in Bio”, add the hashtag #EUCodeWeekChallenge and mention @CodeWeekEU.
Click here to download this challenge as a word document.