Writing a program is a Snap!

  • Snap class
    • A simple Snap programSnap is a simplified programming language using blocks as the instruction statement.
    • Each block represents a line of code.
    • Each block indicates what options it can handle.
    • Right click on a block to get help about that block.
    • In order to save your work, signup for an account by clicking on the cloud, on the snap page.
    • Helpful links:
  • What is a program, also called scripts in snap?
    • A collection of instructions on what to do.
    • A simple Snap program

      A simple Snap program

    • A control block, start when space bar pressed.
    • A motion block to position the sprite.
    • A variable block to create spiral with a value of 1.
    • An operator block to cleat, set the pen to a known state.
    • An operator block to lower the pen.
    • A control block to create a loop, repeating the enclosed blocks 500 times.
    • A block to move the sprite spiral steps.
    • A block to turn the sprite 15 degrees counter clockwise.
    • A block to add .1 to the variable spiral.



  • Hello World
    A simple snap script

    Hello World!

    • Your first script is “Hello World”. A simple set of instructions to print a message. In snap print equates to say.


  • simple loop
    • In a simple loop you establish a count for the loop. Then an instruction or set of instructions to perform. After the instruction set is performed the count is decremented and the execution returns to the start of the loop.  In the image here the beginning of the loop is the repeat block. It will repeat the instructions inside it 500 times. Try changing the the count from 500 to another number and see how it affects the sprites movement.


  • Conditional loop
    • In a conditional loop a condition is tested and the loop continues until that condition is met.

      Conditional loop

      Conditional loop


    • This script will start when the up arrow is pressed. Declares and sets the variable spiral to 0. Then loops until spiral equals 5 The loop starts by saying Hello for .5 seconds and nothing for .5 seconds. then adds 1 to spiral and repeats the loop until the stated condition spiral= 5 is met, ending the script.

      Condition test

      Condition test

    • Notice the image above, the spiral variable is placed in the first square and the value to match is placed in the second square. The whole statement is then placed in the option slot of repeat until to be the condition to meet, ending the loop


  • Now you create a looping script!

Part II

About jcoffey

This entry was posted in commentary, Programming and tagged , , . Bookmark the permalink.