how to build a brick wall using snap! (build your …...if/else logic statement “if” •the...

12
How to build a brick wall using SNAP! (Build Your Own Blocks) For NCSU CSC 200 By Josh Santora

Upload: others

Post on 03-Feb-2020

8 views

Category:

Documents


1 download

TRANSCRIPT

How to build a brick wall using SNAP! (Build Your Own Blocks) For NCSU CSC 200

By Josh Santora

Along with Manual 2, use slides to reverse engineer your own brick wall program

Use NCSU SNAP! program

1. Make all of your variables

2. Make all of the lower-level blocks

3. Build 2nd level blocks

4. Build main block and implement script variables

• Try to keep individual blocks as simple as possible

• Initialize pen and initialize position will be in the main script block, but transitions can also be done with a modified “initialize position” block

Make Variables

Simple building blocks

Regular brick Half brick

More simple blocks

Space between bricks Initialize pen

Use variables in blocks

Initialize position “Y start” variable will be dynamic

(will change as program runs)

2nd Level blocks

Draw row A Draw row B

Main Block

Top half Bottom half

If/else logic statement

“If”

• The ‘if’ statement uses a nested operator • Click ‘help’ over the “mod”

operator to see what it does

• This operation tells whether to build an odd or even number of rows

• Top half of ‘if’ statement builds walls with an even number of rows

If/else logic statement

“Else”

• Conversely, the ‘else’ half of the control block builds walls with an odd number of rows

Links

• Josh's XML code for "brick wall"

• Back to Josh's Homepage