Pages

Friday 24 May 2019

Quick Charades - DTE

What have you been learning?

In DTE we have been learning to use and code the sphero through the sphero Edu app. First, we played with the sphero to become comfortable using it. After a few lessons of playing with the sphero, we learnt how to code it by watching videos such as 'Block 1' through to 'Block 4' from the Sphero EDU App. For 'Block 1' we've learnt how to use 'Loops' codes by making a square using the sphero. 'Block 2' we've learnt how to use the 'If/Then Else' codes by coding the 'Toss Game'. 'Block 3' we've learnt to use 'Gyroscope' code to measure rotational velocity by making a spinning top using the sphero. For 'Block 4' we've learnt how to create 'Variables' by coding a game called 'Hot Potato' using the sphero. After weeks of learning how to code the sphero, we decided to create a game by putting what we've learnt into one program. I've created a game called 'Quick Charades'. Here are my instructions on how to play the game and codes to create it.

Instruction:

1. Throw the sphero and wait for it to produce a random animal sound.
2. After the sphero produced a random animal sound, try and act it as quick as possible.
3. If the people you're playing with agreed with what you've acted and guessed the animal, you can then pass the sphero to one of them.
4. After a couple of minutes playing the unlucky player will be out. You will know you are out if the sphero says "You're Out".
5. Repeat from instruction number 1.

Coding


  1.  Create your own program.
  2. Take the stabilisation block from movement category and put it under the on start program block.
  3. Take the speak block from sound category and put it under the stabilisation block.
  4. Take the loop forever block from controls category and put it under the speak block.
  5. Go to the variables category and create a variable. Name the first one to expire, chose the variable type number and set the default value to 0. Do the same steps as number four but name it 'Toss'.
  6. Put the set block into the loop forever block and set it to expire.
  7. Go to operators, take the random integer operator and put it into the right side of the set block, keep the random integer operator an integer or 'int'.
  8. On the left side of the random integer operator put number 3 and on the right side put 10. This makes it 3 to 10 tosses before the game expires.
  9. Take the loop until block and place under the set expire block.
  10. Go to the comparators category, take the basic comparator block, place it into the true section of the loop until block and select greater than.
  11. Go to variables, then take the toss variable and place it to the left side of the basic comparator.
  12. For the right side of the basic comparator, place the expire variable.
  13. You then write a code comment on the loop until block by holding on the block or right-clicking it. Write "Loop until the toss variable is greater than the expire variable then call the blocks within".
  14. Go to controls, take the if/then else block and place it in the loop until block.
  15. Take the basic comparator from the comparators category, set it to greater than and place it in the true section of the if/then else block.
  16. Go to the sensors category, take the accelerometer sensor, select the total axis and place it in the left side of the basic comparator block.
  17. On the right side of the basic comparator block type number 3.
  18. Then add a code comment saying "Call the "if" logic if the sphero reads more than 3 gees".
  19. Take the main LED block from lights category and place it in the if/then else block. Set the colour to green.
  20. Then take the sound block from sounds category and place it under the main LED block.
  21. Select the animal category and choose the random animal and choose 'wait'.
  22. Take the set block from variables, choose 'toss' and place it under the sound block.
  23. Place the basic operator to the right of the set block and change it to addition. Place the toss variable on the left side of the plus and on the right side, change the 0 to 1.
  24. Grab the main LED block and place it in the else part of the if/then else. Change the colour to red.
  25. Go to the controls category, grab the delay block and place it within the loop forever block. Change the number to 1 second.
  26. Grab the sound block from the sounds category, choose the game category and select the 'You lose' sound. Place this block under the delay block.
  27. Take the main LED from lights category, change the colour to yellow and place it under the sound block.
  28. Go to the movements category, grab the raw motor block and place it under the main LED block. Set both the left and right motors to 255 and the duration for 2 seconds.
  29. Grab another delay block, place it under the raw motor block and set it to 1 second.
  30. To let the players know they are out, take the speak block, write "You're out" and place it under the delay block.
  31. For the last part, grab a set block, select 'Toss' and place it under the speak block.
  32. Now you are done coding.

What did you learn?

I've learnt how to use different blocks to code the sphero. Examples of these blocks are variable blocks, sensors blocks, movement blocks, and so much more. 

What will you do next time?

Next time I would try to create a different game with different codes.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.