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
hong_kong_students_click_here [2015/07/23 10:27]
ffpaladin
hong_kong_students_click_here [2015/07/23 14:50] (current)
ffpaladin
Line 277: Line 277:
 } }
  
 +</​code>​
 +
 +Moving Ball
 +
 +<​code>​
 +
 +int counter;
 +int x = 0;
 +int y = 0;
 +
 +int dx = 5;
 +int dy = 2;
 +
 +void setup() {  //setup function called initially, only once
 +  size(500, 500);
 +}
 +
 +void draw() {  //draw function loops 
 +  ​
 +  background(0);​
 +  ​
 +  ellipse(x,​y,​20,​20);​
 +
 +  if (x > 500) {
 +    dx = dx * -1;
 +  }
 +
 +  if (x < 0) {
 +    dx = dx * -1;
 +  }
 +
 +  if (y > 500) {
 +    dy = dy * -1;
 +  }
 +
 +  if (y < 0) {
 +    dy = dy * -1;
 +  }
 +  ​
 +  x = x + dx;
 +  y = y + dy
 +  ​
 +  if (mousePressed) {
 +   x = mouseX;
 +   y = mouseY;
 + }
 +}
 </​code>​ </​code>​
/soe/sherol/.html/teaching/data/attic/hong_kong_students_click_here.1437672431.txt.gz · Last modified: 2015/07/23 10:27 by ffpaladin