User Tools

Site Tools


spcs:summer2014:d6

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
spcs:summer2014:d6 [2014/07/22 11:48]
ffpaladin
spcs:summer2014:d6 [2014/07/22 17:18]
ffpaladin [Part 4 - JS Platformer (Teams, if you have time)]
Line 18: Line 18:
   * http://​hereistoday.com/​   * http://​hereistoday.com/​
  
-Buggy Sorting Code+Non Animating Sort
  
 <code java> <code java>
  
-// defining the array 
  
-int cheesesticks [] = {21, 33, 44, 22 ,55 ,66 ,77, 33, 22, 11, 44, 33, 22, 11, 55 ,66, 5, 2, 100, 20}; +// GLOBAL VARIABLES
-  +
-// counters +
-int i = -1; +
-int j = 0;+
  
-// storing the minimum ​ 
-int min; 
-  
  
-// setup runs once+int [] array = {90,​60,​70,​50,​40,​30,​20,​10,​1,​80};​ 
 + 
 +// int i, j, k, l; 
 + 
 +// SETUP FUNCTION - Runs Once 
 void setup () { void setup () {
-  
-  size (800,800); 
-  
-  for (int k=0; k<20; k++) 
-    println(cheesesticks[i]);​ 
-} 
-  
-// runs foreverrrrr! (not really) 
  
-void draw () { +  size(500,500); 
-  +   
-  ​background(0)+  ​int min = 0;      // index of the array 
-  +   
-  // only runs after j reaches 20  ​ +  ​ 
-  ​if ((j == 20) && (i < 19)) { +  // outer for-loop 
-  +  ​for (int i=0; i<10; i++) { 
-     i++; +     
-     j=i+1; +    min = i; 
-     ​min = cheesesticks[i]+     
-  } +    // inner for-loop 
-  +    ​for ​(int j=i; j<10; j++) { 
-  ​// runs as long as j is less than 20 +      if (array[j] < array[min]
-  ​if ​(j < 20) { +        min = j;
-  +
-    ​if (cheesesticks[j] < min){ +
-      min = cheesesticks[j]; +
-      int temp = cheesesticks[i];​ +
-      cheesesticks[i] = cheesesticks[j];​ +
-      cheesesticks[j] = temp;+
     }     }
-    ​j++;+    ​ 
 +    // swapping 
 +    int temp = array[i]; 
 +    array[i] = array[min];​ 
 +    array[min] = temp;
   }   }
-  
   ​   ​
-  // Draws the state of the cheesesticks  ​ +  ​for (int k=0; k<10; k++) 
-  ​fill ​(0,0,255);+    println(array[k]);​ 
 +    
 +
 + 
 + 
 +// DRAW LOOP - Infinite Loop 
 + 
 +void draw () {
    
-  ​for (int l=0; l<20; l++) +  ​background(255,0,0); 
-  ​+ 
-    rect(0l*20, cheesesticks[l]*5,​ 10); +  ​ellipse(mouseX, mouseY, 20, 20); 
-  } +
-   +
-  println("​poop"​);​ +
-  ​+
 } }
  
Line 153: Line 142:
 ===== Part 1: Blog and Github (Review) ===== ===== Part 1: Blog and Github (Review) =====
  
-  - Blog: All your completed projects (you don't have to blog if you still want to work on them, but if you are done, blog what you have).+  - Blog: All your completed projects (you don't have to blog if you still want to work on them, but if you are done, blog what you have). ​Get them up on Github like we talked about in class. http://​processingjs.org/​articles/​p5QuickStart.html ​
   - Blog: ALAN TURING. You must address these points:   - Blog: ALAN TURING. You must address these points:
     - Mention the new movie coming out     - Mention the new movie coming out
Line 161: Line 150:
     - Put an image in your post     - Put an image in your post
  
-===== Part 2: Bouncing Balls: Objects and Collision (Teams) =====+---- 
 + 
 +===== Part 2: Visual Sorting II. Spend 20-30 min (Yesterday Teams) ===== 
 + 
 +**Option 1:** For those who've not gotten their sorts working, here's my selection sort from class. It's a little buggy: http://​pastebin.com/​hVFvXvD2 
 + 
 +**Option 2:** If you are done your sort, take the beginning of class to add the following to the sort program: 
 +  - A Pause Button 
 +  - A Start Button 
 +  - A Reset Button 
 + 
 +**Option 3:** If you'd rather work on your Seurat (Pixel Splotches), then you can create a way to change the ellipse sizes while within the running program. 
 + 
 +Remember, if your partner is done with the project, to Fork it into your own directory. Forking will allow you to continue the project on your own. You can keep a copy for yourself. 
 + 
 +Everything on gh-pages! 
 + 
 +---- 
 + 
 +===== Part 3: Bouncing Balls: Objects and Collision (Today Teams) =====
  
 Review: Go back to the lecture on Bouncing Balls. Try to create your own Ball class that can bounce around the screen. Review: Go back to the lecture on Bouncing Balls. Try to create your own Ball class that can bounce around the screen.
Line 173: Line 181:
  
 You must create a Ball class. Read: http://​www.processing.org/​tutorials/​objects/​ You must create a Ball class. Read: http://​www.processing.org/​tutorials/​objects/​
- 
  
 See this sample code for the Car class. See this sample code for the Car class.
Line 233: Line 240:
 </​code>​ </​code>​
  
-===== Part 3: Processing (Teams) - Around the world for Mousey =====+---- 
 + 
 +===== Part 4: Processing (Today Teams) - Around the world for Mousey =====
  
 Mousey the Mouse wants to visit each of you next month. Download a world map, NOT the one on this page. Any kind of world map will do (as long as it's a valid image file format). Find out where everyone lives in the class and help Mousey plan the shortest possible trip. You will approximate the locations based off of the map you choose. Mousey has a jetpack and starts at Stanford. Mousey the Mouse wants to visit each of you next month. Download a world map, NOT the one on this page. Any kind of world map will do (as long as it's a valid image file format). Find out where everyone lives in the class and help Mousey plan the shortest possible trip. You will approximate the locations based off of the map you choose. Mousey has a jetpack and starts at Stanford.
Line 248: Line 257:
  
 ==== Step 2: An object that has x and y ==== ==== Step 2: An object that has x and y ====
 +
 +Try to see if you can create objects like you did for the ball classes.
  
 ==== Step 3: Adjacency Matrix ==== ==== Step 3: Adjacency Matrix ====
Line 257: Line 268:
 Using some algorithm... Maybe Breadth First Search, draw a path that on the screen that highlights what's going on in the code. See example of lines above. Using some algorithm... Maybe Breadth First Search, draw a path that on the screen that highlights what's going on in the code. See example of lines above.
  
-==== Step 5: Travelling ​Sales Person ====+REMINDER: Shortest Path is NOT the Traveling Sales Person problem. TSP is much harder. You do not have to return home like the image above. 
 + 
 +==== Step 5: Traveling ​Sales Person ​(Optional) ​====
  
 Find the shortest distance that Mousey can go INCLUDING his return home. Find the shortest distance that Mousey can go INCLUDING his return home.
Line 263: Line 276:
 ==== Step 6: Animation ==== ==== Step 6: Animation ====
  
-Now make the program animate!+Now make the program animate! ​(or interactive) 
 + 
 +One idea is to be able to change Mousey'​s start location.
  
 ---- ----
  
-===== Part - JS Platformer =====+===== Part - JS Platformer ​(Teams, if you have time) =====
  
 Cookbook! You know what to do. Cookbook! You know what to do.
/soe/sherol/.html/teaching/data/pages/spcs/summer2014/d6.txt · Last modified: 2014/07/22 17:18 by ffpaladin