aboutsummaryrefslogtreecommitdiffstats
path: root/flipdot
diff options
context:
space:
mode:
Diffstat (limited to 'flipdot')
-rw-r--r--flipdot/flipdot.pde58
1 files changed, 58 insertions, 0 deletions
diff --git a/flipdot/flipdot.pde b/flipdot/flipdot.pde
new file mode 100644
index 0000000..6738128
--- /dev/null
+++ b/flipdot/flipdot.pde
@@ -0,0 +1,58 @@
+import processing.net.*;
+
+int x, y;
+int scale = 8;
+int i, j;
+boolean[][] flipped;
+Client c;
+boolean change;
+
+int h = 16, w = 112;
+
+
+void setup()
+{
+ size(112*scale, 16*scale);
+ flipped = new boolean[w][h];
+ c = new Client(this, "192.168.23.222", 6210);
+ c.write("c");
+}
+
+void draw() {
+ background(0);
+ noStroke();
+
+ x = (mouseX - (mouseX % scale)) / scale;
+ y = (mouseY - (mouseY % scale))/ scale;
+
+ println("x, y: " + x + " " + y);
+
+ if( mousePressed &&
+ (x < w && x >= 0) &&
+ (y < h && y >= 0) ) {
+ flipped[x][y] = mouseButton == LEFT;
+
+
+ if ( flipped[x][y] ) {
+ c.write("1" + char(x) + char(y));
+ } else {
+ c.write("0" + char(x) + char(y));
+ }
+ }
+
+ for(i = 0; i < w; i++) {
+ for(j = 0; j < h; j++) {
+ if( flipped[i][j] ) {
+ fill(204, 255, 0);
+ } else {
+ fill(0, 0, 0);
+ }
+
+ rect(i*scale, j*scale, scale, scale);
+ }
+ }
+
+ fill(92, 92, 92);
+ rect(x*scale, y*scale, scale, scale);
+}
+