Skip to content

Commit 3025e61

Browse files
authored
Add files via upload
1 parent 0245797 commit 3025e61

File tree

13 files changed

+881
-0
lines changed

13 files changed

+881
-0
lines changed

TicTacToe_3D/Buttons.pde

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
2+
3+
// Tab Buttons
4+
5+
void SetupButtons() {
6+
7+
int CmdButtonsX = width-90;
8+
int CmdButtonsAbstand = 40;
9+
10+
// Pre-Init: Alle AUS
11+
for(int i=0; i<btnLength; i++) {
12+
rectBt[i] = new RectButton( 1,1, 20,20, col1, col2, false);
13+
}
14+
15+
// Init Knöpfe im 1D-Array
16+
rectBt[1] = new RectButton( CmdButtonsX, CmdButtonsAbstand *1+33, 79,28, col1, col2, true);
17+
rectBt[1].Text ="New";
18+
19+
/* rectBt_1D[2] = new RectButton( CmdButtonsX, CmdButtonsAbstand *2+33, 79,28, col1, col2, true);
20+
rectBt_1D[2].Text ="Reset"; */
21+
22+
rectBt[2] = new RectButton( CmdButtonsX, CmdButtonsAbstand *2+33, 79,28, col1, col2, true);
23+
rectBt[2].Text ="Quit";
24+
}
25+
26+
// -----------------------------------------------------------------------------------------------
27+
28+
class Button {
29+
int x, y;
30+
int sizeX;
31+
int sizeY;
32+
color basecolor, highlightcolor;
33+
color currentcolor;
34+
boolean over = false;
35+
boolean pressed = false;
36+
boolean Exists = false;
37+
String Text = "";
38+
39+
void update() {
40+
if (over() ) {
41+
currentcolor = highlightcolor;
42+
}
43+
else {
44+
currentcolor = basecolor;
45+
}
46+
} // update
47+
48+
boolean pressed() {
49+
if ( over()) {
50+
locked = true;
51+
return true;
52+
}
53+
else {
54+
locked = false;
55+
return false;
56+
}
57+
} // pressed;
58+
59+
boolean over() {
60+
return true;
61+
}
62+
63+
boolean overRect(int x, int y, int width, int height) {
64+
if (mouseX >= x && mouseX <= x+width &&
65+
mouseY >= y && mouseY <= y+height) {
66+
return true;
67+
}
68+
else {
69+
return false;
70+
}
71+
}
72+
}
73+
74+
class RectButton extends Button {
75+
public RectButton(int ix, int iy, int isizeX, int isizeY, color icolor, color ihighlight, boolean iExist) {
76+
x = ix;
77+
y = iy;
78+
sizeX = isizeX;
79+
sizeY = isizeY;
80+
basecolor = icolor;
81+
highlightcolor = ihighlight;
82+
currentcolor = basecolor;
83+
Exists = iExist;
84+
Text = "";
85+
}
86+
87+
boolean over() {
88+
if( overRect(x, y, sizeX, sizeY) ) {
89+
over = true;
90+
return true;
91+
}
92+
else {
93+
over = false;
94+
return false;
95+
}
96+
}
97+
98+
void display() {
99+
if (Exists ) {
100+
stroke(255);
101+
fill(currentcolor);
102+
rect(x, y, sizeX, sizeY);
103+
if (Text != "") {
104+
fill(0, 102, 153);
105+
textAlign(CENTER);
106+
textSize(16) ;
107+
text(Text, (x + (sizeX / 2.0)), (y + (sizeY / 2.0))+5);
108+
}
109+
}
110+
}
111+
}

TicTacToe_3D/GameField.pde

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
2+
3+
4+
void GameField() {
5+
6+
// draw depending from Type of GameField
7+
8+
if (record) {
9+
beginRaw("superCAD.ObjFile", "output.obj");
10+
}
11+
12+
iBox=0;
13+
14+
switch(letterGameFieldType) {
15+
case 'A':
16+
//GameField2();
17+
break;
18+
case 'N':
19+
GameField3();
20+
break;
21+
case 'C':
22+
//GameField1();
23+
break;
24+
case 'S':
25+
//GameField4();
26+
break;
27+
case 'B':
28+
//GameField5();
29+
break;
30+
case 'D':
31+
break;
32+
default: // Default executes if the case labels
33+
println("None *****************"); // don't match the switch parameter
34+
break;
35+
} // switch
36+
37+
if (record) {
38+
endRaw();
39+
record = false;
40+
}
41+
} // GameField
42+
43+
// ----------------------------------------------------------------------------------------------------------------------
44+
45+
void GameField3() {
46+
// with spheres & boxes
47+
for (int n = 0; n < 3; n++ ) {
48+
for (int j = 0; j < 3; j = j+1) {
49+
for (int k = 0; k < 3; k = k+1) {
50+
51+
if (myArray[n][j][k] == constFeldExistiertNicht) {
52+
// field does not exist
53+
// do nothing
54+
}
55+
else if (myArray[n][j][k] == constFeldLeer) {
56+
// field empty
57+
stroke(10,10,10);
58+
noFill();
59+
fill(204, 102, 0);
60+
OneField(n,j,k);
61+
}
62+
else if (myArray[n][j][k] == constFeldBelegtO) {
63+
// field full Letter O
64+
fill(204, 102, 0);
65+
OneField(n,j,k);
66+
fill(204, 102, 0);
67+
OneSphere(n,j,k);
68+
}
69+
else if (myArray[n][j][k] == constFeldBelegtX) {
70+
// field full - Letter X
71+
fill(204, 102, 0);
72+
OneField(n,j,k);
73+
fill(204, 102, 0);
74+
OneLetterX(n,j,k);
75+
}
76+
else {
77+
// Fehler
78+
println("Fehler 3 bei Feldstatus 0,1,2: " + myArray[j][k]);
79+
// Abbruch
80+
exit();
81+
}
82+
}
83+
}
84+
}
85+
}
86+
87+
// ---------------------------------------------------------------------------------
88+
89+
void OneField ( int z1, int x1, int y1) {
90+
// Box: Shape3D
91+
float X_Add = 420;
92+
float Y_Add = 670;
93+
float Z_Add = 5;
94+
95+
float resultX = x1 * 150 + X_Add;
96+
float resultY = z1 * 58 + Y_Add;
97+
float resultZ = y1 * 155 + Z_Add;
98+
99+
// Help for setSize(float width, float height, float depth)
100+
boxBoard[iBox].setSize(80, 5, 80);
101+
boxBoard[iBox].moveTo(resultX, resultY, resultZ);
102+
boxBoard[iBox].tagNo = iBox;
103+
boxBoard[iBox].draw();
104+
iBox++;
105+
106+
}
107+
108+
// Tools ---------------------------------------------
109+
110+
void InitBoxes () {
111+
// boxes = fields of the board
112+
for (int i=0; i<27;i++) {
113+
boxBoard[i] = new Box( this, 40, 5, 40 );
114+
}
115+
}
116+
117+
void OneSphere ( int z1, int x1, int y1) {
118+
// (sphere or) toroid
119+
120+
noStroke();
121+
fill(4, 102, 2);
122+
float X_Add = 420;
123+
float Y_Add = 650; // 717
124+
float Z_Add = 2;
125+
126+
127+
float resultX = x1 * 150 + X_Add;
128+
float resultY = z1 * 58 + Y_Add;
129+
float resultZ = y1 * 160 + Z_Add;
130+
131+
translate( resultX, resultY, resultZ);
132+
133+
paintO () ;
134+
translate(-( resultX), -( resultY), -( resultZ));
135+
stroke(0,0,0);
136+
}
137+
138+
void OneLetterX ( int z1, int x1, int y1) {
139+
140+
float X_Add = 420;
141+
float Y_Add = 650;
142+
float Z_Add = 2;
143+
144+
float resultX = x1 * 150 + X_Add;
145+
float resultY = z1 * 58 + Y_Add;
146+
float resultZ = y1 * 160 + Z_Add;
147+
148+
pushMatrix();
149+
150+
translate( resultX, resultY, resultZ);
151+
fill(234, 2, 2);
152+
paintX () ;
153+
translate( -resultX, -resultY, -resultZ);
154+
popMatrix();
155+
}

TicTacToe_3D/Help.pde

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
// Help
4+
5+
void HelpMsgBox() {
6+
7+
MsgBox ("This is more a test than a full program. Only 2 Players can play each other. You can't play against the Computer. "+
8+
"Credits: shapes3D&peasyCam&ControlP5.",
9+
SpielTitel+ " ("+numVersion+")");
10+
11+
}

0 commit comments

Comments
 (0)