intro to processing

84
Intro to Processing Game with US Beginner Tutorial

Upload: yuma

Post on 07-Jan-2016

38 views

Category:

Documents


1 download

DESCRIPTION

Intro to Processing. Game with US Beginner Tutorial. Welcome!!. Who I am What is Processing? Basic Coding Input Methods Images Classes Arrays. Who I am. Mike Sheinin m [email protected] Interactive Systems Design Computer Science - PowerPoint PPT Presentation

TRANSCRIPT

Intro to Processing

Intro to ProcessingGame with US Beginner TutorialWelcome!!Who I amWhat is Processing?Basic CodingInputMethodsImagesClassesArrays

Who I amMike [email protected]

Interactive Systems DesignComputer Science

Jelly Polo: https://www.youtube.com/watch?v=U-tEU-lVArE

What is Processing?Text-based drawing programSimilar to Java

http://www.processing.orghttp://www.openprocessing.org

Basic CodingProcessing basicsCommandsVariablesConditionalsIterationProcessing basicsvoid setup()Runs oncevoid draw()Runs until the program endssize(x, y)background(r, g, b)(0, 0) is top left size(200, 200) means the bottom right is (200, 200)Processing basicsThe semi-colon ;UPPER and lower caseWhitespaceVariable typesObject-oriented programming language= is assignment == is comparisonProcessing basics&& is and|| is or// and /*...*/ are comments! Means not != means not equal to{} curly brackets for code blocksCommandsline(x, y, x2, y2);ellipse(x, y, r, r);rect(x, y, w, h);point(x, y);fill(r, g, b);noStroke();println();CommandsParametersline(x, y, x2, y2);ellipse(x, y, r, r);VariablesTypeNameValue (not always)

int x = 5;TypeNameValueVariablesTypesintfloatbooleanlongdoublecolorbyteAny classes you makeVariablesCastingCan change types to make them the sameint x = int(random(1, 5)); random() gives a float valuex needs an int valueint() changes the float to an int

VariablesDeclare (above setup)int x;Initialize (in setup)x = 5;Use (in draw)x = x + 1;x += 1;x++VariablesSome variables are managed for youint mouseX Current X position of the mouseint mouseYCurrent Y position of the mouseboolean mousePressedWhether the mouse button is currently pressedchar keyWhich key was typedVariablesGlobal variablesEverything can see itLocalOnly local can see itConditionalsIfIf, elseElse ifConditionalsif(){//do this}Conditionalsif(x = 5){ellipse(50, 50, 20, 20);}

What do the numbers in the ellipse command mean?Is this allowed?Conditionalsif(x == 5){ellipse(50, 50, 20, 20);}

Correct wayThe previous slide uses assignment, not comparisonConditionalsif(x == 5){//do this}else{//do this}Conditionalsif(x == 5){//do this}else if(x == 4){//do this}Conditionalsif(x == 5){//do this}else if(x == 4){//do this}else{//do this}Iteration (Loops)There are two kinds of loopsFor loopsWhile loopsIteration (Loops)For loopAssignmentStopping conditionIncrementBody

for(; ; ){//body}Iteration (Loops)For loop

int i;for(i = 0; i < 10; i++){println(i);}Iteration (Loops)For loop

for(int i = 0; i < 10; i++){println(i);}Iteration (Loops)While loop

while(){//do something}Iteration (Loops)While loop

while(x < 10){println(x);x++;}Iteration (Loops)Nested loops

int i;int j;for(i=0; i