User Tools

Site Tools


spcs:2015:day4

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
spcs:2015:day4 [2015/07/08 01:15]
ffpaladin [Homework]
spcs:2015:day4 [2015/07/09 00:57]
ffpaladin [Class Assignments]
Line 1: Line 1:
-====== Day Wednesday ​======+====== Day Thursday ​======
  
 ===== Activities ===== ===== Activities =====
Line 11: Line 11:
 ===== Class Assignments ===== ===== Class Assignments =====
  
-  ​- **Processing:​ Physics** - Create objects that represent physics. You can make it more realistic, like with gravity if you are able. +  - **Processing:​ Visual Sort** - Write a program that sorts 20 bars visually using various sorts or a sort of your choice
-  ​- **Processing:​ Visual Sort** - Write a program that sorts 20 bars visually using various sorts. +    Step 1sort integers: 
-  **ProcessingSimulation** ​Pick simulation ​that will teach me something. +      ​Input: ​list of random numbers ​that you pick 
-  **ProcessingMake Game** ​To make a game, give it interactions and a winning condition (Ludus and Paida)+      Output: a list out numbers in order 
-  - **Processing: ​Interaction** - Make any of the above MORE interactive.+    ​Step 2: make it visual with rectangles 
 +    - http://​visualgo.net/​sorting.html 
 +  - **Processing: ​Seurat Painting** - How do we make a Seurat Painting animation in Processing 
 +    - Step 1: Make an animation 
 +    - Step 2: Make it so that the user can change the size of the circle
   - **Github** - You can store your processing projects directly there and run them with Processing.js - Read: http://​processingjs.org/​articles/​jsQuickStart.html (Similar to yesterday)   - **Github** - You can store your processing projects directly there and run them with Processing.js - Read: http://​processingjs.org/​articles/​jsQuickStart.html (Similar to yesterday)
- 
  
 ===== Homework ===== ===== Homework =====
Line 23: Line 26:
   * **Blog Post**: Every project should have a post. If you made 3 projects, then there are 3 posts. Have images for what you did. Link to the github.io website online so people can see each program.   * **Blog Post**: Every project should have a post. If you made 3 projects, then there are 3 posts. Have images for what you did. Link to the github.io website online so people can see each program.
   * **Blog Post**: Write about programming languages. How do computers understand instructions?​ What language do they use? What language do we use to give computers instructions?​ Explain what are high and low level languages and how computers can understand our code (talk about compilers).   * **Blog Post**: Write about programming languages. How do computers understand instructions?​ What language do they use? What language do we use to give computers instructions?​ Explain what are high and low level languages and how computers can understand our code (talk about compilers).
 +  * **Design Doc** - Please finish your address book/​contacts app.
 +    * 1) the address book must be able to look up friends
 +    * 2) the address book must be able to tell you who is calling you
   * **Improve your past work**: Double check your work, and make sure your blog is complete. Make sure you have completed all projects. Finish anything you didn't get to do today. Improve anything that you can! Lots of pictures!!!   * **Improve your past work**: Double check your work, and make sure your blog is complete. Make sure you have completed all projects. Finish anything you didn't get to do today. Improve anything that you can! Lots of pictures!!!
-  * **Blog Post**: Game Review - You Only Live Once+  * **Blog Post**: Game Review - You Only Live Once - www.kongregate.com/​games/​raitendo/​you-only-live-once ​
 Note: From now on ALL game reviews must address Ludus, Paida, and Narrative. Note: From now on ALL game reviews must address Ludus, Paida, and Narrative.
 +
 +<code java>
 +
 +// Selection Sort
 +
 +
 +int list[] = {2, 4 , 9, 6, 3, 8, 4, 1, 2, 5};
 +int min_index = 0;
 +int temp;
 +
 +for (int i = 0; i < 10; i++)          // print the list to see it
 +{
 +  print(list[i] + " ");
 +}
 +
 +  print("​\n"​); ​                       // print a new line
 +
 +for (int i = 0; i < 10; i++)          // start the sort
 +{
 +  min_index = i;                      // set the min_index to the begining of the list
 +  for (int j = i+1; j < 10; j++)      // search the rest of the list to find the min value
 +  {
 +    if (list[min_index] > list[j]) ​   // if the there is a smaller value found, save it!
 +    {
 +      min_index = j;
 +    }
 +  }
 +  ​
 +  temp = list[i]; ​                     // swap the min value to the right place
 +  list[i] = list[min_index];​
 +  list[min_index] = temp; 
 +}
 +  ​
 +for (int i = 0; i < 10; i++)          // print the list again
 +{
 +  print(list[i] + " ");
 +}
 +
 +</​code>​
  
  
Line 31: Line 76:
  
 **TA: Jeffrey** **TA: Jeffrey**
 +  - Evangelin, Wilson
 +  - Toby, Mike
   - Lisa, Billy   - Lisa, Billy
-  - Chris, Toby 
-  - Mike, Jack 
 **TA: Yinan** **TA: Yinan**
-  - Evangeline, Wilson +  - Cindy, Michael 
-  - Kyle, HollisPeter+  - Kyle, JackBran
 **TA: Kevin** **TA: Kevin**
-  - MichaelBran +  - HollisPeter 
-  - SamuelCindy +  - JeffSamuel 
-  - Jeff, Frank+  - Chris, Frank 
 + 
 + 
 +<code java> 
 + 
 + 
 +// Credit: RadioTech@Github 
 +// Visual Sort 
 + 
 +int i = 0, j = 0; 
 +int tempcheesestick;​ 
 +int sticks = 40; 
 + 
 +int[] cheesesticks = new int [sticks]; 
 +int[] oldsticks = new int [sticks]; 
 + 
 +void setup() { 
 +   
 +   
 +  size(500,​400);​ 
 +  for(int fi = 0; fi < sticks; fi++){ 
 +    cheesesticks[fi] = round(random(500));​ 
 +    oldsticks[fi] = cheesesticks[fi];​ 
 +  } 
 +
 + 
 +void draw() { 
 +   
 +   
 +  if(j>​-1){ 
 +     
 +     
 +    if(i>​-1){ 
 +      if(cheesesticks[i]>​cheesesticks[i+1]){ 
 +        tempcheesestick = cheesesticks[i]; ​  
 +        cheesesticks[i] = cheesesticks[i+1];​ 
 +        cheesesticks[i+1] = tempcheesestick;​ 
 +      } 
 +       
 +      i++; 
 +      if(i >= sticks-1){ 
 +         i = 0; 
 +         ​j++;​ 
 +      } 
 +    } 
 +     
 +     
 +    if(j >= sticks-1){ 
 +       j = -1;  
 +    } 
 +     
 +  } 
 +   
 +  rectMode(CENTER);​ 
 +  background(255);​ 
 +  for(int fi = 0; fi < sticks; fi++){ 
 +    if(cheesesticks[fi] == oldsticks[fi]){ 
 +       ​fill(255,​200,​0);​  
 +    } else { 
 +       ​fill(255,​0,​0);​  
 +    } 
 +     
 +    rect(cheesesticks[fi]/​2-1,​(400/​sticks)*fi+(400/​sticks)/​2,​cheesesticks[fi],​400/​sticks);​ 
 +  
 +    oldsticks[fi] = cheesesticks[fi];​ 
 +  } 
 +   
 +</​code>​ 
 + 
 +<code java> 
 + 
 +// Car Objects from Processing.org 
 + 
 +// Example: Two Car objects 
 +Car myCar1; 
 +Car myCar2; // Two objects! 
 + 
 +void setup() { 
 +  size(200,​200);​ 
 +  // Parameters go inside the parentheses when the object is constructed. 
 +  myCar1 = new Car(color(255,​0,​0),​0,​100,​2);​  
 +  myCar2 = new Car(color(0,​0,​255),​0,​10,​1);​ 
 +
 + 
 +void draw() { 
 +  background(255);​ 
 +  myCar1.drive();​ 
 +  myCar1.display();​ 
 +  myCar2.drive();​ 
 +  myCar2.display();​ 
 +
 + 
 +// Even though there are multiple objects, we still only need one class.  
 +// No matter how many cookies we make, only one cookie cutter is needed. 
 +class Car {  
 +  color c; 
 +  float xpos; 
 +  float ypos; 
 +  float xspeed; 
 + 
 +  // The Constructor is defined with arguments. 
 +  Car(color tempC, float tempXpos, float tempYpos, float tempXspeed) {  
 +    c = tempC; 
 +    xpos = tempXpos; 
 +    ypos = tempYpos; 
 +    xspeed = tempXspeed;​ 
 +  } 
 + 
 +  void display() { 
 +    stroke(0);​ 
 +    fill(c); 
 +    rectMode(CENTER);​ 
 +    rect(xpos,​ypos,​20,​10);​ 
 +  } 
 + 
 +  void drive() { 
 +    xpos = xpos + xspeed; 
 +    if (xpos > width) { 
 +      xpos = 0; 
 +    } 
 +  } 
 +
 + 
 +</​code>​ 
 + 
 +<code java> 
 + 
 +// Credit: Neel 
 + 
 +int[] cheesesticks = {200, 40, 170, 50, 70, 60, 80, 90, 190, 150, 100, 110, 120, 140, 180, 130, 20, 160, 30, 10}; 
 + 
 +int i = -1; 
 +int j = 0; 
 +int min; 
 + 
 +void setup() { 
 +  size (250, 250); 
 +
 + 
 +void draw() { 
 +   
 +  background(200);​ 
 +   
 +  // only runs after j reaches 20   
 +  if ((j == 20) && (i < 19)) { 
 +  
 +     ​i++;​ 
 +     ​j=i+1;​ 
 +     min = cheesesticks[i];​ 
 +  } 
 +  
 +  // runs as long as j is less than 20 
 +  if (j < 20) { 
 +  
 +    if (cheesesticks[j] < min){ 
 +      min = cheesesticks[j];​ 
 +      //swap 
 +      int temp = cheesesticks[i];​ 
 +      cheesesticks[i] = cheesesticks[j];​ 
 +      cheesesticks[j] = temp; 
 +    } 
 +    j++; 
 +  } 
 +   
 +  fill(#​EA5353);​ 
 + 
 +for (int i=0; i<20; i++) 
 +  { 
 +    rect(0, i*10,​cheesesticks[i],​ 5); 
 +  } 
 + 
 +}  
 + 
 +</​code>​ 
/soe/sherol/.html/teaching/data/pages/spcs/2015/day4.txt · Last modified: 2015/07/09 05:26 by ffpaladin