Difference between revisions of "Today"

From CodeStuff
Jump to: navigation, search
Line 18: Line 18:
 
var cx=320;
 
var cx=320;
 
var cy=240;
 
var cy=240;
var power=1;
+
var power=0.1;
 
var penSize=4;
 
var penSize=4;
  
Line 30: Line 30:
 
   lastx=cx;
 
   lastx=cx;
 
   lasty=cy;
 
   lasty=cy;
 +
 
 +
  cx=cx+dx;
 +
  cy=cy+dy;
 
    
 
    
 
     // the arrow keys have key codes 37,38,39 and 40
 
     // the arrow keys have key codes 37,38,39 and 40
Line 48: Line 51:
 
     cx+=power;
 
     cx+=power;
 
   }
 
   }
    
+
 
 +
   if (keyIsDown(32)) {
 +
    clear();
 +
  }
 +
 
 +
  if (cx>640 ) {
 +
    cx=640;
 +
  }
 +
 
 +
  if (cy>480) {
 +
    cy=480;
 +
  }
 +
 
 +
  if (cx <0) {
 +
    cx=0;
 +
  }
 +
 
 +
  if (cy <0) {
 +
    cy=0;
 +
  }
 
    
 
    
 
   setColour("purple");
 
   setColour("purple");
 
   fillCircle(cx,cy,penSize);
 
   fillCircle(cx,cy,penSize);
 +
 +
  setColour("red");
 +
 
 
    
 
    
 
}
 
}

Revision as of 06:48, 26 June 2017

Useful things to refer to.

The API page has a list of some of the functions you can use such as


This program is also available at http://jsbin.com/kizubop/1/edit?js,output