Link to the project or level: (Game Lab - Code.org)
What I expect to happen: Student wants the dice animations to alternate randomly when a key is pressed.
What actually happens: Nothing, yet.
What I’ve tried: We considered using a random number block inside a set animation block, but that would not change the animation randomly.
Unfortunately, the sharing permissions are not available on this link. You’ll need to update the sharing permissions in the class dashboard so we can see it. Sounds like a neat idea! Can’t wait to see it.
Sorry about that. Here is a screenshot of the code; since we can’t figure out how to randomize, the thumbprint won’t produce, so we can’t
Thanks for sharing your code … a few observations for you.
Do you want 6 different sprites or just 1 sprite that can have 6 different faces?
If you create a sprite and set its animation to be one of the six animations to begin with, the question then becomes, how do I randomly change the animation to one of the other 5 animations?
Here is some pseudocode that may help.
- Rename all of your animations in the animation tab with a number (1, 2, 3, 4, 5 & 6).
- Create a variable at the top of your code … something like “face”.
- When you click “g” change the value of the variable to = a random number between 1 & 6.
- Set the animation to equal face. – This part is actually tricky though because your animation names (1-6) will be “strings” (text) and the variable will be a number.
Have your student give it a shot and check back in if it still isn’t working quite right.
Thanks for the tips, Mike!
Here’s what we’ve tried. What do you suggest?
This looks great! You are only one small step away from it working. On line 6 of your code, the variable should be called “face”. Dice is your sprite and Face would be the number represented on the dice.
If you make that one change, I think it will work!
That worked great! Thank you SO much!