diff options
| author | Tim Redfern <tim@eclectronics.org> | 2012-01-08 18:57:07 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2012-01-08 18:57:07 +0000 |
| commit | 3246dbd20364c64927f59bb3daf159de0df2b198 (patch) | |
| tree | 191539030243ece7a9e90e118a8551838aed259b /test/netchasketch.pde | |
| parent | 68f0c8ed8283cff46133eb798c24afabae2cfca2 (diff) | |
Diffstat (limited to 'test/netchasketch.pde')
| -rw-r--r-- | test/netchasketch.pde | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/test/netchasketch.pde b/test/netchasketch.pde index 0a856c5..74089c0 100644 --- a/test/netchasketch.pde +++ b/test/netchasketch.pde @@ -7,7 +7,7 @@ void setup() { size(300,300); background(50,50,50); stroke(0,0,0); - fill(50,50,50,5); + fill(50,50,50); x=width/2; y=height/2; shaking=false; @@ -18,11 +18,27 @@ void draw() { rect(0,0,width,height); //println("SHAKEN"); } + if (mousePressed) { + int x1,y1,xo,yo; + dx=dy=0; + xo=mouseX-x; + yo=mouseY-y; + if (xo!=0) { + dx=xo/abs(xo); + if (yo/xo>2) dx=0; + } + if (yo!=0) { + dy=yo/abs(yo); + if (xo/yo>2) dy=0; + } + } line(x,y,x+dx,y+dy); x+=dx; y+=dy; - x=min(width,max(0,x)); - y=min(height,max(0,y)); + x=x%width; + if (x<0) x+=width; + y=y%width; + if (y<0) y+=height; } void keyPressed() { @@ -60,3 +76,6 @@ void keyReleased() { break; } } +void mouseReleased() { + dx=dy=0; +} |
