Difference between revisions of "Today"

From CodeStuff
Jump to: navigation, search
Line 14: Line 14:
  
  
<edcode>
+
<edcode>var cx=320;
 
+
var cx=320;
+
 
var cy=240;
 
var cy=240;
  
var qx=200;
+
var maryx=200;
var qy=240;
+
var maryy=240;
  
 
var power=0.1;
 
var power=0.1;
Line 54: Line 52:
 
   if (keyIsDown(39)) {
 
   if (keyIsDown(39)) {
 
     cx+=power;
 
     cx+=power;
   }
+
   }
 
+
  if (keyIsDown(32)) {
+
    clear();
+
  }
+
 
    
 
    
 +
  //keep cx onscreen
 
   if (cx>640 ) {
 
   if (cx>640 ) {
 
     cx=640;
 
     cx=640;
 
   }
 
   }
 
    
 
    
 +
  if (cx <0) {
 +
    cx=0;
 +
  }
 +
 
 +
  //keep cy onScreen
 
   if (cy>480) {
 
   if (cy>480) {
    cy=480;
+
    cy=480;
 +
  }
 +
   
 +
  if (cy <0) {
 +
    cy=0;
 
   }
 
   }
 
    
 
    
   if (cx <0) {
+
  //move mary towards cx,cy
     cx=0;  
+
   if (maryy < cy) {
 +
     maryy+=0.3;
 
   }
 
   }
 
    
 
    
  if (cy <0) {
 
    cy=0;
 
  }
 
 
    
 
    
 +
  if (keyIsDown(32)) {
 +
    clear();
 +
  }
 +
 
 +
   
 
   setColour("purple");
 
   setColour("purple");
 
   fillCircle(cx,cy,penSize);
 
   fillCircle(cx,cy,penSize);
  
 
   setColour("red");
 
   setColour("red");
   fillCircle(qx,qy,penSize);
+
   fillCircle(maryx,maryy,penSize);
 
    
 
    
 
}
 
}

Revision as of 09:14, 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