summaryrefslogtreecommitdiff
path: root/test/netchasketch.pde
diff options
context:
space:
mode:
Diffstat (limited to 'test/netchasketch.pde')
-rw-r--r--test/netchasketch.pde62
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;
+ }
+}