THE TEAL EDITION                 LIZ RUTLEDGE                 rutle173@newschool.eduDAY 4            esrutledge@gmail.comA...
agenda.        Review:                                     Do:        Homework                                    PsuedoCo...
review.                                                             now wasn’t that fun?        homework:        questions...
curves.                                     like using the Illustrator pen tool...wearing a blindfold.          Curves Exa...
conditionals!                                                       the tool that allows you to do anything of            ...
if statements.                                                        1. The test must be an expression that resolves to t...
if-else statements.                                                           adding complexity.        = a tree diagram m...
logical operators.                                            sometimes one condition just                                ...
the “NOT” operator.            The logical NOT operator is an exclamation mark. It inverts the            logical value of...
random.                                                      sometimes you just need some random values.       The random(...
text and images!                          finally, something other than                                                sha...
pseudocode.                                                   organize your thoughts to make the coding                   ...
more pseudocode.        example:        if ((mouse position is in left half of canvas) AND (mouse position is in top half ...
a bouncing ball.                                                        let’s try out our sweet new                       ...
homework.                                                                    optional subheading goes here.       do:     ...
Upcoming SlideShare
Loading in...5
×

Bootcamp - Team TEAL - Day 4

851

Published on

Slides from in-class lecture

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
851
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Bootcamp - Team TEAL - Day 4

  1. 1. THE TEAL EDITION LIZ RUTLEDGE rutle173@newschool.eduDAY 4 esrutledge@gmail.comAugust 4, 2011 cell phone: 415.828.4865
  2. 2. agenda. Review: Do: Homework PsuedoCode +,-,*,% Logic for Ball Bounce Data Types - String, int, float Variables - assigning and good labelling practices Learn: Drawing Curves Operators - &&, ||, !=, ==, > Conditionals - if, and, or, random, noise Displaying text in the sketch window - PFont, Create/Load Font, text() PImageDAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  3. 3. review. now wasn’t that fun? homework: questions? let’s put that bad boy together topics we covered yesterday: +,-,*,% Data Types - String, int, float Variables - assigning and good labelling practicesDAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  4. 4. curves. like using the Illustrator pen tool...wearing a blindfold. Curves Example: http://www.openprocessing.org/visuals/?visualID=2124DAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  5. 5. conditionals! the tool that allows you to do anything of any actual interest...tever. the operators: examples: > greater than println(3 > 5); // Prints what? <= less than or equal to < less than println(3 >= 5); // Prints what? == equality println(5 >= 3); // Prints what? >= greater than or equal to != inequality println(3 == 5); // Prints what? println(5 == 5); // Prints what? what do they do? println(5 != 5); // Prints what? return a boolean value of whether or not the expression is in fact trueDAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  6. 6. if statements. 1. The test must be an expression that resolves to true or false. sample code: 2. When the test expression evaluates to true, the code inside the if (test) { brackets is run. If the expression is false, the code is ignored. statements 3. Code inside a set of braces is called a block. } examples: int x = 150; if (x > 100) { // If x is greater than 100, ellipse(50, 50, 36, 36); // draw this ellipse } if (x < 100) { // If x is less than 100 rect(35, 35, 30, 30); // draw this rectangle } line(20, 20, 80, 80);DAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  7. 7. if-else statements. adding complexity. = a tree diagram made of code. if (test) { statements; } else { else = execute only if first test statements 2; is not met } if (test) { statements; } else if (test2) { else if = execute only if first test is statements 2; not met AND second test IS met }DAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  8. 8. logical operators. sometimes one condition just isn’t enough. examples: int a = 10; int b = 20; && = AND if ((a > 5) || (b < 30)) { line(20, 50, 80, 50); || = OR } // Will the code in the block run? ! = NOT if ((a > 15) || (b < 30)) { ellipse(50, 50, 36, 36); } // Will the code in the block run?DAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  9. 9. the “NOT” operator. The logical NOT operator is an exclamation mark. It inverts the logical value of the associated boolean variables. It changes true to false, and false to true. The logical NOT operator can be applied only to boolean variables. examples: boolean b = true; // Assign true to b println(b); // Prints “true” println(!b); // Prints “false” println(!x); // ERROR! It’s only possible to ! a boolean variableDAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  10. 10. random. sometimes you just need some random values. The random() function creates unpredictable values within the range specified by its parameters. random(high) => returns a random number between 0 and the high parameter random(low, high) => returns a random number between the low and the high parameter examples: float f = random(5.2); // Assign f a float value from 0 to 5.2 int i = random(5.2); // ERROR! Why? int j = int(random(0,5.2)); // Assign j an int value from 0 to 5 println(j); Use random sparingly and be conscious of the math and algorithm of a range of numbers, rather than choosing random. Often used for color...but hey, let’s make our ranges specific!DAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  11. 11. text and images! finally, something other than shapes! PFont() How to use it: createFont(); loadFont(); text(); PImage() How to use it: image();DAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  12. 12. pseudocode. organize your thoughts to make the coding part faster, easier and more accurate. example: if(stomach grumbling) { eat something, stupid! } else if (sleepy) { just go to bed; } else { keep watching tv like a lazy bum; }DAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  13. 13. more pseudocode. example: if ((mouse position is in left half of canvas) AND (mouse position is in top half of canvas)) { draw a orange rectangle in top left quarter of screen; } else { draw a yellow rectangle in bottom right quarter of screen; }DAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  14. 14. a bouncing ball. let’s try out our sweet new pseudocode skillz. in-class activity: go over logic of a bouncing ball as a class.DAY 4Tuesday, 4 Aug 2011 CODE bootcamp 2011
  15. 15. homework. optional subheading goes here. do: 1) Write pseudocode for bouncing balls 2) Add label/text to drawing from the green painting tiles in an interesting way (i.e. not just a line of text in the middle of the screen) extra credit: 3) Write pseudocode for bouncing balls that respond realistically. Think the physics of a billards table.DAY 4Tuesday, 4 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.

×