DOC PREVIEW
GT LCC 6310 - Loops, Animation, and Simple User Interaction

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:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Computation as an Computation as an Expressive MediumExpressive MediumLab 1: Loops, Animation, Lab 1: Loops, Animation, and Simple User Interactionand Simple User InteractionMicah HorvatMicah Horvat*Slides blatantly stolen from Annie Lausier, which were blatantly stolen *Slides blatantly stolen from Annie Lausier, which were blatantly stolen from Jason Alderman, which were blatantly stolen from Mayhew Seavey. from Jason Alderman, which were blatantly stolen from Mayhew Seavey. The cycle continues.The cycle continues.Lab HoursLab HoursAny suggestions?Any suggestions?I’ll send out an e-mail by the end I’ll send out an e-mail by the end of the day with with lab hours of the day with with lab hours And always feel free to e-mail And always feel free to e-mail me if you have questions: me if you have questions: [email protected]@mail.gatech.eduhttp://www.lcc.gatech.edu/~mazalek/courses/fall07/lcc6310/What have you gone What have you gone over?over?Window size and coordinate systemWindow size and coordinate systemCommenting codeCommenting codeVariablesVariablesDrawing primitivesDrawing primitivespointpointlinelinerectrectellipseellipsetriangletriangleprint() and println()print() and println()if(boolean){ do something }else{ do if(boolean){ do something }else{ do something} logicsomething} logic(0,0)xyWhat will we go over?What will we go over?Courseware!Courseware!Variables: A RecapVariables: A RecapDrawing primitives (more info)Drawing primitives (more info)Java Control Flow: LoopingJava Control Flow: LoopingThe Processing “draw()” looping The Processing “draw()” looping function for animationfunction for animationSimple mouse interactionSimple mouse interactionVariablesVariablesVariables are placeholders for Variables are placeholders for your data.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, Double, Double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 example, a “String” object is a series of Char variables.Char variables.More info on drawing More info on drawing primitivesprimitivesZooooom on over to the Zooooom on over to the reference pages…reference pages…Java Control FlowJava Control FlowIf-Then-Else: Conditional LogicIf-Then-Else: Conditional Logicint i = 5;if(i > 10) {drop_it_like_its_hot();}else if(i > 3) {park_it_like_its_hot();}else {pop_it_like_its_hot();}Java Control Flow: Java Control Flow: LoopingLooping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 wanted to change all of the lines to start 5 pixels higher, instead.Java Control Flow: Java Control Flow: LoopingLooping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 wanted to change all of the lines to start 5 pixels higher, instead.What if we could run this same line of code multiple times, only changing these two numbers?Java Control Flow: Java Control Flow: While LoopsWhile LoopsWhile loops can make your dreams come true.While loops can make your dreams come true.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 until the condition in the parentheses is false.Java Control Flow: Java Control Flow: While LoopsWhile LoopsBe careful with loops. Make sure the Be careful with loops. Make sure the condition will eventually return condition will eventually return false, or else it will go forever.false, or else 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, and run infinitely. Your dreams will soon become nightmares!Java Control Flow: For Java Control Flow: For LoopsLoops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 loop will run all the way through, then i will increment, and the inside loop will run again.Java Control Flow: Nested Java Control Flow: Nested LoopsLoopsStill confused? Let’s look at Still confused? Let’s look at this thing closer.this thing 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 Still confused? Let’s look at this thing closer.this thing closer.for(int i = 10; i <= 100; i += 10) { for(int j = 10; j <= 100; j += 10) { point(i, j); }}ijSets j to 10. That’s all for now.Java Control Flow: Nested Java Control Flow: Nested LoopsLoopsStill confused? Let’s look at Still confused? Let’s look at this thing


View Full Document

GT LCC 6310 - Loops, Animation, and Simple User Interaction

Documents in this Course
Load more
Download Loops, Animation, and Simple User Interaction
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 Loops, Animation, and Simple User Interaction 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 Loops, Animation, and Simple User Interaction 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?