Code a Dice to Roll
This challenge has been written by Fabrizia Agnello and is part of the EU CODE WEEK CHALLENGES.
Target Audience
- Teachers and educators
- Primary School students (6 to 12 years)
- Lower Secondary School students (12 to 16 years)
Experience
- Beginner
Duration
- 1 hour
Purpose
- To enhance creativity in coding.
- To code a simulation of a randomly moving object to be used if the real object is not available
Recommended Materials
Description
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.
Instructions
- 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.
Example
Roll a D-20 dice: https://scratch.mit.edu/projects/877857926
Click here to download this challenge as a word document.
Copyright notice ©
The EU Code Week website for schools is a service supported by the European Commission
Except where stated otherwise, content made available on this site is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license
Licensing under Creative Commons licenses does not of itself affect the ownership of the copyright
Content from third party websites is subject to their own copyright restrictions; please refer to the site of origin for more information.
The EU Code Week website for schools is a service supported by the European Commission
Except where stated otherwise, content made available on this site is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license
Licensing under Creative Commons licenses does not of itself affect the ownership of the copyright
Content from third party websites is subject to their own copyright restrictions; please refer to the site of origin for more information.