-
Notifications
You must be signed in to change notification settings - Fork 1
/
tictactoe.scad
136 lines (113 loc) · 2.56 KB
/
tictactoe.scad
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// tic-tac-toe board by Hugomatic and Basbrun
//
// http://basbrun.com
// http://hugomatic.ca
//
// contact: hugo@hugomatic.ca
//
// License:
// Copying is not stealing, but cheating at tic-tac-toe is meh.
// http://en.wikipedia.org/wiki/Tic-tac-toe
// hide / show the board
//draw_board = false;
draw_board = true;
// hide / show the x and os
//draw_x_and_os = false;
draw_x_and_os = true;
// === BOARD parameters ===
DimX=75; // external board dimensions in mm
DimY=75;
DimZ=6;
// recess for the pockets
BigH=2; // from top to thin walls
SmallH=2; // from thin walls to bottom
BigW=68; // internal size of play area
BorderW=4; // thin wall thickness
// === X and O parameters ===
Width= 18;
Thick=3;
Height=2;
Spacing=24;
// this module draws the board
module tictactoeBase(DimX, DimY,DimZ, BigH, SmallH,BigW, BorderW )
{
PocketWidth = (BigW-(2*BorderW) ) / 3;
difference() {
cube([DimX,DimY,DimZ], center = true);
translate([0,0,(DimZ/2)-(BigH/2)])
{
cube([BigW,BigW,BigH], center = true);
}
union() {
for(i=[-1,0,1])
{
for(j=[-1,0,1])
{
translate([(i*(BigW-(2*BorderW))/3)+i*BorderW,(j*(BigW-(2*BorderW))/3)+j*BorderW,(DimZ/2)-((SmallH+BigH)/2)])
{
cube([PocketWidth, PocketWidth, SmallH+BigH], center = true);
}
}
}
}
}
}
// this module generates a single O
module o_piece(Width, Thick, Height)
{
difference()
{
cylinder(r=Width / 2, h=Height, center=true);
cylinder(r=Width / 2 - Thick , h=Height, center=true);
}
}
// this module generates a single X
module x_piece(Width, Thick, Height)
{
x=2 * Width;
y = Thick;
z = Height;
w = Width;
difference()
{
union()
{
rotate([0,0,45])
cube( [x,y,z], center=true);
rotate([0,0,-45])
cube( [x,y,z], center=true);
}
difference()
{
cube([x,x,z], center=true);
cube([w, w, z], center=true);
}
}
}
// this modules draws multiple X and Os
module x_and_os(Width, Thick, Height, Spacing)
{
for (i=[-Spacing, 0, Spacing])
{
// top line, all X
translate([i,Spacing,0])
x_piece(Width, Thick, Height);
// bottom line, all Os
translate([i,-Spacing,0])
o_piece(Width, Thick, Height);
}
x_piece(Width, Thick, Height);
translate([-Spacing,0,0])
x_piece(Width, Thick, Height);
translate([Spacing,0,0])
o_piece(Width, Thick, Height);
}
if (draw_board)
{
tictactoeBase(DimX, DimY, DimZ, BigH, SmallH, BigW, BorderW);
}
if(draw_x_and_os)
{
x_and_os(Width, Thick, Height, Spacing);
}