class TicTacSquare { final static int XMARK = 1; final static int OMARK = 2; final static int NOMARK = 0; int marker = NOMARK; int sx,sy,swidth,sheight; color scolor = color(255); color mcolor = color(0); int mweight = 5; int moffset = 10; color winColor = color(255,0,0); TicTacSquare(int _sx, int _sy, int _swidth, int _sheight) { sx = _sx; sy = _sy; swidth = _swidth; sheight = _sheight; } void drawSquare() { fill(scolor); noStroke(); rect(sx,sy,swidth,sheight); stroke(mcolor); strokeWeight(mweight); ellipseMode(CORNERS); if (marker == XMARK) { line(sx+moffset,sy+moffset,sx+swidth-moffset,sy+sheight-moffset); line(sx+swidth-moffset,sy+moffset,sx+moffset,sy+sheight-moffset); } else if (marker == OMARK) { ellipse(sx+moffset,sy+moffset,sx+swidth-moffset,sy+sheight-moffset); } } boolean contains(int x, int y) { if (x < sx + swidth && x > sx && y < sy + sheight && y > sy) { return true; } else { return false; } } void markWin() { scolor = winColor; } void changeMark(int _mark) { if (marker == NOMARK) { marker = _mark; } } }