0
Upcoming SlideShare
×

Bootcamp - Team TEAL - Day 8

932

Published on

functions, variable scope

Published in: Technology, Education
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
932
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
2
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Bootcamp - Team TEAL - Day 8"

1. 1. TEA M TEAL LIZ RUTLEDGEDAY 8 rutle173@newschool.eduAugust 10, 2011 esrutledge@gmail.com
2. 2. agenda. Review: Learn: all that hard stuff. FUNCTIONS! (woooooooot) namely: namely: for loops breaking down logic into mouse/keyboard interaction custom functions if statements variable scope boolean “switches”DAY 8Tuesday, 10 Aug 2011 CODE bootcamp 2011
3. 3. homework now wasn’t that fun? googly eyes! questions? let’s look at a few! review: mouse interaction variables and functions the constrain() and dist() functions trigonometry (*gasp!*) anything else?DAY 8Tuesday, 10 Aug 2011 CODE bootcamp 2011
4. 4. functions! breaking down logic into reuseable little building blocks the concept: being able to separate out bits of logistics/syntax from your code to achieve several different results. notable benefits include: modularity: getting to reuse bits of code from place to place (like variables on crack) readability: by separating out all the crazy math and logic you can more easily see what’s going on when skimming back throughDAY 8Tuesday, 10 Aug 2011 CODE bootcamp 2011
5. 5. how functions work. a quick example. void setup(){ void setup(){ size(400,400); this: size(400,400); strokeWeight(2); strokeWeight(2); fill(255); fill(255); } } void draw() { void draw() { //set fill orange momentarily drawOrangeCircle(); fill(255, 120, 0); //remove stroke momentarily //white square with 2pt stroke noStroke(); rect(100, 100, 50, 50); //draw circle ellipse(50,50,20,20); drawOrangeCircle(); //replace stroke } strokeWeight(2); //replace fill void drawOrangeCircle() { fillv(255); //set fill orange momentarily fill(255, 120, 0); //white square with 2pt stroke //remove stroke momentarily rect(100, 100, 50, 50); noStroke(); //draw circle //set fill orange momentarily ellipse(50,50,20,20); fill(255, 120, 0); //replace stroke //remove stroke momentarily noStroke(); turns strokeWeight(2); //replace fill //draw circle ellipse(50,50,20,20); into } fill(255); //replace stroke strokeWeight(2); this: //replace fill fill(255); }DAY 8Tuesday, 10 Aug 2011 CODE bootcamp 2011
6. 6. variable scope. functions aren’t all fun and games. the concept: “what happens in brackets stays in brackets” in english please? variables defined INSIDE a function can only be used inside THAT PARTICULAR function. (hint: think the i incrementing variable in a for loop) variables defined OUTSIDE of a function can be used in that and any other function on that same level. (we’re specifying “on that same level” because you can actually have a function...INSIDE a function. but we won’t worry about that yet.)DAY 8Tuesday, 10 Aug 2011 CODE bootcamp 2011
7. 7. homework. due Thursday, August 11th. brainstorm! think about your final project ideas play around with potential tools/techniques you might want to use also: catch up on any oustanding assignmentsDAY 8Tuesday, 10 Aug 2011 CODE bootcamp 2011
1. A particular slide catching your eye?

Clipping is a handy way to collect important slides you want to go back to later.