Difference between revisions of "Today"
From CodeStuff
| Line 1: | Line 1: | ||
| − | + | Useful things to refer to. | |
| − | + | *[[Variables]] | |
| + | *[[If statements]] | ||
| + | *[[Coordinates]] | ||
| − | + | The [[API|API page]] has a list of some of the functions you can use such as | |
| − | + | *[[API#clear();|clear()]] | |
| + | *[[API#fillCircle_.28x.2C_y.2C_radius.29.3B|fillCircle()]] . | ||
| + | *[[API#keyIsDown.28keyCode.29|keyIsDown()]] . | ||
| − | + | <edcode> | |
| − | + | var cx=320; | |
| − | + | var cy=240; | |
| − | + | var power=1; | |
| − | + | var penSize=4; | |
| − | + | var lastx=cx; | |
| − | + | var lasty=cy; | |
| − | + | ||
| − | + | ||
| − | + | function move() { | |
| + | var dx = cx-lastx; | ||
| + | var dy = cy-lasty; | ||
| − | + | lastx=cx; | |
| − | + | lasty=cy; | |
| − | + | ||
| − | + | // the arrow keys have key codes 37,38,39 and 40 | |
| − | + | ||
| − | + | if (keyIsDown(38)) { | |
| + | cy-=power; | ||
| + | } | ||
| − | + | if (keyIsDown(40)) { | |
| + | cy+=power; | ||
| + | } | ||
| − | + | if (keyIsDown(37)) { | |
| − | } | + | cx-=power; |
| + | } | ||
| − | + | if (keyIsDown(39)) { | |
| − | + | cx+=power; | |
| − | + | } | |
| + | |||
| + | |||
| + | setColour("purple"); | ||
| + | fillCircle(cx,cy,penSize); | ||
| + | |||
} | } | ||
| − | + | run(move); | |
| − | + | </edcode> | |
| − | + | ||
| − | + | This program is also available at http://jsbin.com/kizubop/1/edit?js,output | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
Revision as of 00:58, 23 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