Successfully reported this slideshow.

Bootcamp - Team TEAL - Day 7

1,041 views

Published on

Mouse and keyboard interaction!

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Bootcamp - Team TEAL - Day 7

  1. 1. TEA M TEAL LIZ RUTLEDGEDAY 7 rutle173@newschool.eduAugust 9, 2011 esrutledge@gmail.com
  2. 2. agenda. Review: Learn: All that hard stuff that just MOUSE INTERACTION! keeps ACCUMULATING! (yayyyyyyyyy) namely: namely: if-statements mouseX, mouseY conditional operators pmouseX, pmouseY nested if-statements mousePressed the dreaded for loop mouseReleasedDAY 7Tuesday, 9 Aug 2011 CODE bootcamp 2011
  3. 3. homework now wasn’t that fun? the for-loop parade: questions? let’s look at a few! review: the structure of a for loop why we use for loops anything else?DAY 7Tuesday, 9 Aug 2011 CODE bootcamp 2011
  4. 4. mouse interaction! finally the good stuff! the concept: actually being able to include user input in your sketch through the position and activity of their mouse and keyboardDAY 7Tuesday, 9 Aug 2011 CODE bootcamp 2011
  5. 5. mouse position. home is where their mouse is. the syntax: mouseX, mouseY the location of the user’s mouse pmouseX, pmouseY the location of the user’s mouse exactly one loop ago note: this allows you to very easily get the CHANGE in mouse position (i.e. which direction the user is moving his/her pointer)DAY 7Tuesday, 9 Aug 2011 CODE bootcamp 2011
  6. 6. mouse inputs. clicks, drags, movements, etc. variables. mousePressed (boolean) tells you if the mouse button is pressed mouseButton variable that tells you which button was clicked (LEFT or RIGHT) functions. these allow you to create entire series of events every time corresponding condition has occurred mousePressed() mouseReleased() mouseDragged() mouseMoved() mouseClicked()DAY 7Tuesday, 9 Aug 2011 CODE bootcamp 2011
  7. 7. keyboard inputs. variables. keyPressed (boolean) whether or not a key (any key) is pressed } only useful inside key which key is being pressed (ex: ‘a’, ‘b’, ‘B’, ‘x’, ‘ ‘ ) as string one of the below functions or an if- keyCode which key is being pressed if a non-ASCII key as a CODE statement testing for keyPressed (ex: BACKSPACE, TAB, ENTER, RETURN, ESC, and DELETE) functions. these allow you to create entire series of events every time corresponding condition has occurred keyPressed() keyReleased() keyTyped()DAY 7Tuesday, 9 Aug 2011 CODE bootcamp 2011
  8. 8. homework. due Wednesday, August 10pth. do: Keyboard and Mouse Interaction: Googly Eyes! Create a pair of eyes that react to mouse/key input. (ex: Eyes follow your mouse wherever it goes, the eyes blink when you click, and anything else you can think of.) There are two possible versions you can do of this project depending on your comfort level with trigonometry: 1. The “Boooo Trig” Version: Make the eyes rectangles or square and use the constrain() function to limit the pupil position 2. The “Yay Trig!” Version: Make the eyes circular and calculate the positions of the eyes using dist(), sin(), cos(), and acos() or asin(). You might also be able to use the constrain() function based on your approach. extra credit: Square Painter! Create three distinct types of squares to draw (differing in size, fill color, etc) and link each one to a keyboard command (a key or keyCode). The user should be able to press a key to “load their paintbrush” with each one of the square styles and draw them wherever they click like a stamp.DAY 7Tuesday, 9 Aug 2011 CODE bootcamp 2011

×