User Tools

Site Tools


hong_kong_students_click_here

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
Last revision Both sides next revision
hong_kong_students_click_here [2015/07/23 10:27]
ffpaladin
hong_kong_students_click_here [2015/07/23 11:35]
ffpaladin
Line 275: Line 275:
   line(20,​80,​10,​90);​   line(20,​80,​10,​90);​
   line(20,​80,​30,​90);​   line(20,​80,​30,​90);​
 +}
 +
 +</​code>​
 +
 +Moving Ball
 +
 +<​code>​
 +
 +int counter;
 +int x = 20;
 +int dx = 5;
 +int y = 20;
 +int dy = 2;
 +
 +void setup() {  //setup function called initially, only once
 +  size(500, 500);
 +}
 +
 +void draw() {  //draw function loops 
 +  ​
 +  background(0,​0,​0);​
 +  ellipse(x,​y,​20,​20);​
 +  ​
 +  x = x + dx;
 +  y = y + dy;
 + 
 +  if (x > 250) {
 +    dx = dx * -1;
 +  }
 +  ​
 +  if (x < 0) {
 +    dx = dx * -1;
 +  }
 +  ​
 +  if (y > 250) {
 +    dy = dy * -1;
 +  }
 +  ​
 +  if (y < 0) {
 +    dy = dy * -1;
 +  }
 +  ​
 } }
  
 </​code>​ </​code>​
/soe/sherol/.html/teaching/data/pages/hong_kong_students_click_here.txt · Last modified: 2015/07/23 14:50 by ffpaladin