diff options
| author | Tim Redfern <tim@eclectronics.org> | 2012-01-08 12:30:32 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2012-01-08 12:30:32 +0000 |
| commit | 68f0c8ed8283cff46133eb798c24afabae2cfca2 (patch) | |
| tree | 176289ad489b35a0aef786d3702ae873ce6a3c61 /test/netchasketch.pde | |
first commit
Diffstat (limited to 'test/netchasketch.pde')
| -rw-r--r-- | test/netchasketch.pde | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/netchasketch.pde b/test/netchasketch.pde new file mode 100644 index 0000000..0a856c5 --- /dev/null +++ b/test/netchasketch.pde @@ -0,0 +1,62 @@ +//i,j,k,m +int dx,dy; +int x,y; +boolean shaking; + +void setup() { + size(300,300); + background(50,50,50); + stroke(0,0,0); + fill(50,50,50,5); + x=width/2; + y=height/2; + shaking=false; +} + +void draw() { + if (shaking) { + rect(0,0,width,height); + //println("SHAKEN"); + } + line(x,y,x+dx,y+dy); + x+=dx; + y+=dy; + x=min(width,max(0,x)); + y=min(height,max(0,y)); +} + +void keyPressed() { + switch (key) { + case 'm': + dy=1; + break; + case 'i': + dy=-1; + break; + case 'k': + dx=1; + break; + case 'j': + dx=-1; + break; + case 's': + shaking=true; + break; + + } +} +void keyReleased() { + switch (key) { + case 'i': + case 'm': + dy=0; + break; + case 'j': + case 'k': + dx=0; + break; + case 's': + shaking=false; + break; + } +} |
