BYOB/Home

From virtualMV2015wiki
Jump to: navigation, search
 Home   <

Build Your Own Blocks (BYOB)

Resources

BYOB Interface

BYOB Interface
  • BYOB Menu
  • Block Menu
    • Block Options
  • Code Panel
  • Stage
  • Controls

Resetting the environment

Many of the examples given start with a clean environment If you have been playing (which is good) to reset back to the start

  • On the BYOB Menu select File > New

Hello world

  1. Make sure the Scripts tag is active in the coding panel
  2. Select the Looks block
  3. Drag the say Hello! for 2 secs block into the Scripts panel
  4. Change the Hello! to Hello world! by clicking on Hello! and typing Hello World! (this is so you can be a real C programmer one day as the first program real C programmers write is Hello World!)
  5. Now click on the block and the fish (also known as a sprite) will say Hello World for 2 seconds.
BYOB Hello World

Hello World with a control block

Rather than just clicking on the code, we often want to create a sequence of instructions which we then tell the computer to run. In BYOB this is achieved by using the green go flag!. So, to add this

  1. Select the Control Block options
  2. The first block is when flag clicked". Drag this above the say Hello Word for 2 secs and lock them together.
  3. Now click on the green flag on the controls menu, and your program will run.
BYOB Hello World with Flag start

Hello World with some user input

What if our fish sprite would like to say Hello World to you?

Lets get the program to ask for your name then display this in the fishy speech bubble. The user input feature is in the Sensing blocks, so

  1. Drag the ask What's your name? and wait block between the When flag clicked and say Hello World blocks
  2. Now we want to get sneaky. Instead of just typing in Hello World We want the program to join the answer that is typed in to Hello so, if "Rob" say is typed in then the fish bubble will say "Hello Rob".
  3. To do that we need to include an operator into the say block.
    • Select the Operators Block Menu
    • Drag the join 'Hello' 'World' block onto the Hello World of the say block
    • If you run this there should be no change in the program.(see tip following)
  4. The ask block puts the answer in a special location called a variable (or something that can change). BYOB by default calls this variable Answer. So ..
    • Change to the Sensing blocks, and you will see the variable answer listed with a check box.
    • Drag answer over the top of world in the say block
  5. Now click on the green flag on the controls menu, and your program will run.
    • Fish bubble says 'What is your name' and an input box appears at the bottom of the screen. Enter your name and the fish bubble says "Hello ..yourname.."

Note: If you click the check box of the variable, this will display the variable and its value on the stage. This can be very useful when testing that your program is doing what its meant to.

Tip: Modern programmers get used to iterative program testing (or test as you go) this avoids complicated de-bugging later on. Also, it is good practice to save different versions of your program, so if you do make a mess (which happens a lot!!) you can always go back to a good version (You may want to number them by adding v01, v02, etc.. to the filename)

So this should have got you started into the world of programming. Remember that computers are REALLY not smart, they will follow your instructions exactly whether they are right or WRONG!!

Simple movement

Simple movement


Number Guessing game

Number Guessing game

Notes:

  • Click on the image to make it larger
  • In order for you to do this you will need to Make a Variable called TheNumber.
  • A random number generator is a cool technique when you want to create a guessing game, or you want to introduce some random behaviours.

Note there are some logic (or semantic) errors in here. That means that the program runs ok (or the Syntax is ok) but there are some things not quite right.

Extensions:

  • Once you have worked out how to move the sprite you could always make the fish loop instead of just saying "Wow.. you guessed" ..
  • Add a low sound if too low, and a high sound if too high and a congratulations sound when correct
  • Count the number of guesses (this will need you to create a variable that increases by 1 each time a guess is made)

Icon References.png References

  1. Harvey, B. & Mönig, J.(2010) Bringing “No Ceiling” to Scratch: Can One Language Serve Kids and Computer Scientists?. Retrieved from http://byob.berkeley.edu/BYOB.pdf

BYOB/Home. (2017). In virtualMV's ( Michael Verhaart ) wiki. Retrieved May 23, 2017, from http://www.virtualmv.com/wiki/index.php?title=BYOB/Home    (zotero)