game with us beginner tutorial. welcome!! who i am what is processing? basic coding input methods...

84
Intro to Processing Game with US Beginner Tutorial

Upload: haven-moberly

Post on 14-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

  • Slide 1

Game with US Beginner Tutorial Slide 2 Welcome!! Who I am What is Processing? Basic Coding Input Methods Images Classes Arrays Slide 3 Who I am Mike Sheinin [email protected] Interactive Systems Design Computer Science Jelly Polo: https://www.youtube.com/watch?v=U-tEU- lVArEhttps://www.youtube.com/watch?v=U-tEU- lVArE Slide 4 What is Processing? Text-based drawing program Similar to Java http://www.processing.org http://www.openprocessing.org Slide 5 Basic Coding Processing basics Commands Variables Conditionals Iteration Slide 6 Processing basics void setup() Runs once void draw() Runs until the program ends size(x, y) background(r, g, b) (0, 0) is top left size(200, 200) means the bottom right is (200, 200) Slide 7 Processing basics The semi-colon ; UPPER and lower case Whitespace Variable types Object-oriented programming language = is assignment == is comparison Slide 8 Processing basics && is and || is or // and /*...*/ are comments ! Means not != means not equal to {} curly brackets for code blocks Slide 9 Commands line(x, y, x2, y2); ellipse(x, y, r, r); rect(x, y, w, h); point(x, y); fill(r, g, b); noStroke(); println(); Slide 10 Commands Parameters line(x, y, x2, y2); ellipse(x, y, r, r); Slide 11 Variables Type Name Value (not always) int x = 5; TypeNameValue Slide 12 Variables Types int float boolean long double color byte Any classes you make Slide 13 Variables Casting Can change types to make them the same int x = int(random(1, 5)); random() gives a float value x needs an int value int() changes the float to an int Slide 14 Variables Declare (above setup) int x; Initialize (in setup) x = 5; Use (in draw) x = x + 1; x += 1; x++ Slide 15 Variables Some variables are managed for you int mouseX Current X position of the mouse int mouseY Current Y position of the mouse boolean mousePressed Whether the mouse button is currently pressed char key Which key was typed Slide 16 Variables Global variables Everything can see it Local Only local can see it Slide 17 Conditionals If If, else Else if Slide 18 Conditionals if( ) { //do this } Slide 19 Conditionals if(x = 5) { ellipse(50, 50, 20, 20); } What do the numbers in the ellipse command mean? Is this allowed? Slide 20 Conditionals if(x == 5) { ellipse(50, 50, 20, 20); } Correct way The previous slide uses assignment, not comparison Slide 21 Conditionals if(x == 5) { //do this } else { //do this } Slide 22 Conditionals if(x == 5) { //do this } else if(x == 4) { //do this } Slide 23 Conditionals if(x == 5) { //do this } else if(x == 4) { //do this } else { //do this } Slide 24 Iteration (Loops) There are two kinds of loops For loops While loops Slide 25 Iteration (Loops) For loop Assignment Stopping condition Increment Body for( ; ; ) { //body } Slide 26 Iteration (Loops) For loop int i; for(i = 0; i < 10; i++) { println(i); } Slide 27 Iteration (Loops) For loop for(int i = 0; i < 10; i++) { println(i); } Slide 28 Iteration (Loops) While loop while( ) { //do something } Slide 29 Iteration (Loops) While loop while(x < 10) { println(x); x++; } Slide 30 Iteration (Loops) Nested loops int i; int j; for(i=0; i