aboutsummaryrefslogtreecommitdiffstats
path: root/flipdot/flipdot.pde
blob: 67381281dcc636bcbd85ebab2df1a17d83083380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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);
}