2. Runs once Runs over and over Runs each time you click the mouse A Brief Detour: Mouse and Key Presses
3. Runs once Runs over and over A Brief Detour: Mouse and Key Presses Try replacing mousePressed () with: keyPressed () mouseReleased () mouseDragged () How are these different?
6. Anatomy of a Function (similar words: method, subroutine) void renderCircle(){ fill (200); ellipse (x,y,100,100); } what’s this? what’s this? function code function name
7. Do the same thing in slightly different ways Both circles look the same, but behave differently Functions: Why do I care?
8. If you change the function code, you change how the circles look without changing their behavior Functions: Why do I care? make a different shape here
9. Sometimes it’s just neater and easier to read Functions: Why do I care? Blahblahblah make 6 ellipses in three alternating colors and enclose them in a rectangle that has a randomly changing color and put a line through it all…
10. Anatomy of a Function what’s this? parameters (TYPE and NAME) function code function name void renderCircle( int _x, int _y){ fill (200); ellipse (_x,_y,100,100); }
11. You can use a function to ask a question and receive an answer Functions: Why do I care?
12. boolean inCircle( int _x, int _y){ if ( sq (_x-x) + sq (_y-y) < sq (50)) return true ; else return false ; } Anatomy of a Function data return type parameters (TYPE and NAME) function code function name
13. YOU CAN USE OTHER PEOPLE’S FUNCTIONS Functions: Why do I care?