Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Privacy
Imprint
Contact
Login methods
Sign in
Toggle navigation
Menu
Open sidebar
Mehmet Duhan Tercüman
Connect_Four
Commits
f27f4b39
Commit
f27f4b39
authored
May 24, 2021
by
Mehmet Duhan Tercüman
Browse files
Er kann sich bewegen der Ehrenmann
parent
4ef43180
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/PIS_HU1/Draw.java
View file @
f27f4b39
...
...
@@ -2,15 +2,20 @@ package PIS_HU1;
import
processing.core.PApplet
;
import
java.util.ArrayList
;
public
class
Draw
extends
PApplet
{
boolean
white
=
true
;
boolean
black
=
false
;
int
width
=
600
;
int
height
=
600
;
int
xVar
=
width
/
8
;
int
yVar
=
height
/
8
;
Pawn
[][]
gameBoard
=
new
Pawn
[
8
][
8
];
int
width
=
800
;
int
height
=
800
;
int
xVar
=
width
/
8
;
// Hilfsvariable zum erstellen des Feldes
int
yVar
=
height
/
8
;
// Hilfsvariable zum erstellen des Feldes
ArrayList
<
int
[]>
tmp
=
new
ArrayList
<>();
GameEngine
ge
=
new
GameEngine
();
public
static
void
main
(
String
[]
args
)
{
...
...
@@ -24,13 +29,14 @@ public class Draw extends PApplet {
public
void
setup
()
{
noStroke
();
drawBoard
();
startBoard
();
System
.
out
.
println
(
ge
.
toString
());
}
public
void
draw
()
{
noStroke
();
printPawn
();
}
...
...
@@ -47,7 +53,9 @@ public class Draw extends PApplet {
}
}
public
void
startBoard
()
{
/*
public void showBoard() {
gameBoard[0][1] = new Pawn(this, false, (height / 8) - (xVar / 2), 2 *(height / 8) - (yVar / 2));
gameBoard[0][3] = new Pawn(this, false, (height / 8) - (xVar / 2), 4 * (height / 8) - (yVar / 2));
gameBoard[0][5] = new Pawn(this, false, (height / 8) - (xVar / 2), 6 * (height / 8) - (yVar / 2));
...
...
@@ -74,6 +82,55 @@ public class Draw extends PApplet {
gameBoard[7][6] = new Pawn(this, true, 8 * (height / 8) - (xVar / 2), 7 * (height / 8) - (yVar / 2));
}
*/
public
void
mousePressed
()
{
int
y
=
mouseY
/
100
;
int
x
=
mouseX
/
100
;
if
(!
tmp
.
isEmpty
())
{
int
x1
=
tmp
.
get
(
tmp
.
size
()
-
1
)[
0
];
int
y1
=
tmp
.
get
(
tmp
.
size
()
-
1
)[
1
];
System
.
out
.
println
(
y1
+
" "
+
x1
);
ge
.
gameBoard
[
y1
][
x1
]
=
0
;
System
.
out
.
println
(
"test"
);
fill
(
255
,
206
,
158
);
ellipse
(
x1
*
100
+
50
,
y1
*
100
+
50
,
80
,
80
);
ge
.
move
(
y
,
x
,
1
);
tmp
.
clear
();
System
.
out
.
println
(
ge
.
toString
());
}
else
{
System
.
out
.
println
(
y
+
" "
+
x
);
if
(
ge
.
gameBoard
[
y
][
x
]
!=
0
)
{
int
[]
xy
=
{
x
,
y
};
tmp
.
add
(
xy
);
}
}
}
Pawn
[][]
move
(
Pawn
[][]
Board
,
int
mouseY
,
int
mouseX
)
{
Board
[
mouseY
][
mouseX
]
=
new
Pawn
(
this
,
true
,
mouseX
*
(
height
/
8
)
-
(
xVar
/
2
),
mouseY
*
(
height
/
8
)
-
(
xVar
/
2
));
return
Board
;
}
public
void
printPawn
()
{
for
(
int
i
=
0
;
i
<
8
;
i
++)
{
for
(
int
j
=
0
;
j
<
8
;
j
++)
{
if
(
ge
.
gameBoard
[
i
][
j
]
==
1
)
{
fill
(
0
,
0
,
0
);
ellipse
(
j
*
100
+
50
,
i
*
100
+
50
,
60
,
60
);
}
else
if
(
ge
.
gameBoard
[
i
][
j
]
==
2
)
{
fill
(
255
,
255
,
255
);
ellipse
(
j
*
100
+
50
,
i
*
100
+
50
,
60
,
60
);
}
}
}
}
}
app/src/main/java/PIS_HU1/GameEngine.java
View file @
f27f4b39
package
PIS_HU1
;
public
class
GameEngine
{
int
[][]
gameBoard
=
new
int
[
8
][
8
];
public
GameEngine
(){
gameBoard
[
0
][
1
]
=
1
;
gameBoard
[
0
][
3
]
=
1
;
gameBoard
[
0
][
5
]
=
1
;
gameBoard
[
0
][
7
]
=
1
;
gameBoard
[
1
][
0
]
=
1
;
gameBoard
[
1
][
2
]
=
1
;
gameBoard
[
1
][
4
]
=
1
;
gameBoard
[
1
][
6
]
=
1
;
gameBoard
[
2
][
1
]
=
1
;
gameBoard
[
2
][
3
]
=
1
;
gameBoard
[
2
][
5
]
=
1
;
gameBoard
[
2
][
7
]
=
1
;
gameBoard
[
5
][
0
]
=
2
;
gameBoard
[
5
][
2
]
=
2
;
gameBoard
[
5
][
4
]
=
2
;
gameBoard
[
5
][
6
]
=
2
;
gameBoard
[
6
][
1
]
=
2
;
gameBoard
[
6
][
3
]
=
2
;
gameBoard
[
6
][
5
]
=
2
;
gameBoard
[
6
][
7
]
=
2
;
gameBoard
[
7
][
0
]
=
2
;
gameBoard
[
7
][
2
]
=
2
;
gameBoard
[
7
][
4
]
=
2
;
gameBoard
[
7
][
6
]
=
2
;
}
public
String
toString
(){
String
s
=
" "
;
for
(
int
i
=
0
;
i
<
8
;
i
++){
for
(
int
j
=
0
;
j
<
8
;
j
++){
s
+=
""
+
gameBoard
[
i
][
j
];
}
s
+=
" \n"
;
}
return
s
;
}
public
void
move
(
int
y
,
int
x
,
int
playerTurn
){
gameBoard
[
y
][
x
]=
playerTurn
;
}
}
app/src/main/java/PIS_HU1/Pawn.java
View file @
f27f4b39
...
...
@@ -4,14 +4,17 @@ import processing.core.PApplet;
public
class
Pawn
{
PApplet
a
;
int
y
,
x
;
int
playerTurn
;
public
Pawn
(
PApplet
a
,
boolean
black
,
int
x
,
int
y
){
if
(
black
){
playerTurn
=
1
;
a
.
fill
(
0
,
0
,
0
);
a
.
ellipse
(
this
.
y
=
y
,
this
.
x
=
x
,
4
0
,
4
0
);
a
.
ellipse
(
this
.
y
=
y
,
this
.
x
=
x
,
6
0
,
6
0
);
}
else
{
playerTurn
=
2
;
a
.
fill
(
255
,
255
,
255
);
a
.
ellipse
(
this
.
y
=
y
,
this
.
x
=
x
,
4
0
,
4
0
);
a
.
ellipse
(
this
.
y
=
y
,
this
.
x
=
x
,
6
0
,
6
0
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment