Difference between revisions of "Today"
From CodeStuff
| Line 14: | Line 14: | ||
| − | <edcode> | + | <edcode>var cx=320; |
| − | + | ||
| − | var cx=320; | + | |
var cy=240; | var cy=240; | ||
| − | var | + | var maryx=200; |
| − | var | + | 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; | ||
| − | } | + | } |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| + | //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; | |
| + | } | ||
| + | |||
| + | if (cy <0) { | ||
| + | cy=0; | ||
} | } | ||
| − | if ( | + | //move mary towards cx,cy |
| − | + | if (maryy < cy) { | |
| + | maryy+=0.3; | ||
} | } | ||
| − | |||
| − | |||
| − | |||
| + | if (keyIsDown(32)) { | ||
| + | clear(); | ||
| + | } | ||
| + | |||
| + | |||
setColour("purple"); | setColour("purple"); | ||
fillCircle(cx,cy,penSize); | fillCircle(cx,cy,penSize); | ||
setColour("red"); | setColour("red"); | ||
| − | fillCircle( | + | 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