DOC PREVIEW
GT LCC 6310 - Computers as an Expressive Medium

This preview shows page 1-2-15-16-31-32 out of 32 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Computers as an Expressive MediumLab HoursWhat will we go over?VariablesSlide 5Java Control FlowJava Control Flow: LoopingSlide 8Java Control Flow: While LoopsSlide 10Java Control Flow: For LoopsJava Control Flow: Nested LoopsSlide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Processing: The loop() functionThe loop() functionSlide 25Slide 26Slide 27Slide 28The setup() functionTracking Mouse PositionReacting to Mouse ClicksThat’s It For Today!Computers as an Computers as an Expressive MediumExpressive MediumLab 1: Loops, Animation, and Lab 1: Loops, Animation, and Simple User InteractionSimple User InteractionMayhew SeaveyMayhew SeaveyLab HoursLab HoursThanks for your responses! Here are my lab Thanks for your responses! Here are my lab hours:hours:Tues: 2-4Tues: 2-4Wed: 3-5, 7-9Wed: 3-5, 7-9Thurs: 12-1, 2-3Thurs: 12-1, 2-3Fri: 2-5Fri: 2-5I tried to hit everyone who e-mailed me, but I tried to hit everyone who e-mailed me, but if none of these times work, come tell me.if none of these times work, come tell me.And always feel free to e-mail me if you have And always feel free to e-mail me if you have questions. I’m at questions. I’m at [email protected]@mail.gatech.edu . . If you forget, it’s permanently on the whiteboard If you forget, it’s permanently on the whiteboard in Room 002.in Room 002.http://www.lcc.gatech.edu/~mateas/courses/LCC6310-Fall2004/Syllabus2004.htmlWhat will we go over?What will we go over?Variables: A RecapVariables: A RecapJava Control Flow: LoopingJava Control Flow: LoopingThe Processing “loop()” function for The Processing “loop()” function for animationanimationSimple mouse interactionSimple mouse interactionVariablesVariablesVariables are placeholders for your data.Variables are placeholders for your data.int i; // declares a new variable ii = 1; // assigns the value of 1 to the new variableint j = i + 1; // declares a new variable j, and assigns it to i + 1, which is 2.VariablesVariablesTwo main types: Primitives and ObjectsTwo main types: Primitives and ObjectsPrimitives:Primitives:BooleanBoolean, , CharChar, Byte, Short, , Byte, Short, IntInt, Long, , Long, FloatFloat, , DoubleDoubleObjects:Objects:Everything else. Everything else. Constructed with primitives as a base. For Constructed with primitives as a base. For example, a “String” object is a series of Char example, a “String” object is a series of Char variables.variables.Java Control FlowJava Control FlowIf-Then-Else: Conditional LogicIf-Then-Else: Conditional Logicint i = 5;if(i > 10) {save_the_kitten();}else if(i > 3) {throw_the_kitten();}else {paint_the_kitten();}Java Control Flow: LoopingJava Control Flow: LoopingWant to draw ten lines, evenly-Want to draw ten lines, evenly-spaced apart?spaced apart?line(10, 10, 10, 200);line(20, 10, 20, 200);line(30, 10, 30, 200);...This can get old, fast. Also would be tedious if you This can get old, fast. Also would be tedious if you wanted to change all of the lines to start 5 pixels wanted to change all of the lines to start 5 pixels higher, instead.higher, instead.Java Control Flow: LoopingJava Control Flow: LoopingWant to draw ten lines, evenly-Want to draw ten lines, evenly-spaced apart?spaced apart?line(10, 10, 10, 200);line(20, 10, 20, 200);line(30, 10, 30, 200);...This can get old, fast. Also would be tedious if you This can get old, fast. Also would be tedious if you wanted to change all of the lines to start 5 pixels wanted to change all of the lines to start 5 pixels higher, instead.higher, instead.What if we could run this What if we could run this same line of code multiple same line of code multiple times, only changing these times, only changing these two numbers?two numbers?Java Control Flow: While Java Control Flow: While LoopsLoopsHoly Toledo! We can! Let’s use a while loop!Holy Toledo! We can! Let’s use a while loop!line(10, 10, 10, 200);line(20, 10, 20, 200);line(30, 10, 30, 200);...int i = 10;while(i <= 100) { line(i, 10, i, 200); i = i + 10;}A while loop will run the code inside the brackets repeatedly A while loop will run the code inside the brackets repeatedly until the condition in the parentheses is false.until the condition in the parentheses is false.Java Control Flow: While Java Control Flow: While LoopsLoopsBe careful with loops. Make sure the Be careful with loops. Make sure the condition will eventually return false, or else condition will eventually return false, or else it will go forever.it will go forever.while(true) { ...}int i = 10;while(i > 0) { line(i, 10, i, 200); i = i + 10;}Both of these loops are valid, will compile, Both of these loops are valid, will compile, and run infinitely.and run infinitely.Java Control Flow: For LoopsJava Control Flow: For LoopsFor Loops are just like While loops, but a For Loops are just like While loops, but a bit more compact for simple incrementing, bit more compact for simple incrementing, like in our last example.like in our last example.These two loops are functionally the same:These two loops are functionally the same:int i = 10;while(i <= 100) { line(i, 10, i, 200); i += 10;}for(int i = 10; i <= 100; i += 10) { line(i, 10, i, 200);}(i += 10 is equivalent to i = i + 10)Java Control Flow: Nested Java Control Flow: Nested LoopsLoopsNesting of loops refers to putting one Nesting of loops refers to putting one loop inside the brackets of another.loop inside the brackets of another.for(int i = 10; i <= 100; i += 10) { for(int j = 10; j <= 100; j += 10) { point(i, j); }}What does this mean? It means that the inside What does this mean? It means that the inside loop will run all the way through, then loop will run all the way through, then ii will will increment, and the inside loop will run again.increment, and the inside loop will run again.Java Control Flow: Nested Java Control Flow: Nested LoopsLoopsStill confused? Let’s look at this thing Still confused? Let’s look at this thing closer.closer.for(int i = 10; i <= 100; i += 10) { for(int j = 10; j <= 100; j += 10) { point(i, j); }}ijSets i to 10. That’s all for now.Java Control Flow: Nested Java Control Flow: Nested LoopsLoopsStill confused? Let’s look at this thing Still confused? Let’s look at this thing closer.closer.for(int i = 10; i <= 100; i += 10) { for(int j = 10; j <= 100; j += 10) { point(i, j); }}ijSets j


View Full Document

GT LCC 6310 - Computers as an Expressive Medium

Documents in this Course
Load more
Download Computers as an Expressive Medium
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Computers as an Expressive Medium and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Computers as an Expressive Medium 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?