Added all pieces

This commit is contained in:
Filip Znachor 2023-03-07 14:59:58 +01:00
parent e3ee468f4e
commit a578df5d60
13 changed files with 456 additions and 0 deletions

55
assets/archer.svg Normal file
View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100mm"
height="100mm"
viewBox="0 0 100 100"
version="1.1"
id="svg5"
xml:space="preserve"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="archer.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="1.4218693"
inkscape:cx="195.86892"
inkscape:cy="211.69316"
inkscape:window-width="1850"
inkscape:window-height="973"
inkscape:window-x="35"
inkscape:window-y="32"
inkscape:window-maximized="0"
inkscape:current-layer="layer1"
showguides="false" /><defs
id="defs2" /><g
inkscape:label="Vrstva 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(88.929095,-66.473746)"><path
id="path1000"
style="display:inline;opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.54174"
d="m -58.929095,123.47375 v 7 h 40 v -7 l 5,-36.000004 -25,-21 -25,21 z m 0,7 v 5 h 10 l -9,11 -21,7 v 13 h 80 v -13 l -21,-7 -9,-11 h 10 v -5 z"
sodipodi:nodetypes="ccccccccccccccccccccc" /><ellipse
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:7.83273;stroke-opacity:1"
id="path1445"
cx="-38.929096"
cy="103.38573"
rx="32"
ry="25.5" /><path
style="opacity:1;fill:#efefef;fill-opacity:1;stroke:none;stroke-width:4.89749;stroke-opacity:1"
d="m -41.929095,85.473746 h 6 v 9 h 8.999898 v 6.000004 h -8.999898 v 14 h -6 l 0,-14 h -9 v -6.000004 h 9 z"
id="path1603"
sodipodi:nodetypes="ccccccccccccc" /></g></svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

45
assets/horse.svg Normal file
View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100mm"
height="100mm"
viewBox="0 0 100 100"
version="1.1"
id="svg5"
xml:space="preserve"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="horse.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="1.8096324"
inkscape:cx="69.074802"
inkscape:cy="169.92401"
inkscape:window-width="1920"
inkscape:window-height="1002"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
showguides="false" /><defs
id="defs2" /><g
inkscape:label="Vrstva 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(88.929095,-66.473746)"><path
id="path1092"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.54174"
d="m -58.929095,116.47375 v 8 h 40 l 12,-14 V 84.473746 l -20,-18 h -41 l 7,10 -14,21 1,12.000004 h 15 l 11,-13.000004 3,3 z m 0,14 v 5 h 10 l -9,11 -21,7 v 13 h 80 v -13 l -21,-7 -9,-11 h 10 v -5 z"
sodipodi:nodetypes="ccccccccccccccccccccccccccc" /></g></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

63
assets/king.svg Normal file
View file

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100mm"
height="100mm"
viewBox="0 0 100 100"
version="1.1"
id="svg5"
xml:space="preserve"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="king.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="1.5630461"
inkscape:cx="290.45848"
inkscape:cy="170.50041"
inkscape:window-width="1920"
inkscape:window-height="1002"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
showguides="true" /><defs
id="defs2" /><g
inkscape:label="Vrstva 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(88.929095,-66.473746)"><circle
style="fill:#979797;fill-opacity:1;stroke:none;stroke-width:9.87824;stroke-opacity:1"
id="path1174-6"
cx="-38.929096"
cy="95.473747"
r="23" /><path
d="m -15.929097,94.473746 -7,-7 -8.999998,7 -7,-7 -7,7 -9,-7 -7,7 v -28 h 45.999999 z"
style="fill:#777777;fill-opacity:1;stroke:none;stroke-width:1.54174;opacity:0.53377841"
id="path1184" /><path
id="path1000"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.54174"
d="m -58.929095,118.47375 v 7 h 40 v -7 l 12,-25.000004 -9,6 -7,-7 -9,7 -7,-7 -7,7 -9,-7 -7,7 -9,-6 z m 0,12 v 5 h 10 l -9,11 -21,7 v 13 h 80 v -13 l -21,-7 -9,-11 h 10 v -5 z"
sodipodi:nodetypes="ccccccccccccccccccccccccccc" /><circle
style="display:none;opacity:0.621378;fill:#000000;fill-opacity:1;stroke:none;stroke-width:5.93824"
id="path1068"
cx="-38.929096"
cy="94.473747"
r="20" /><circle
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:4.17052;stroke-opacity:1"
id="path1260"
cx="-38.929096"
cy="72.473747"
r="6" /></g></svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

50
assets/pawn.svg Normal file
View file

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100mm"
height="100mm"
viewBox="0 0 100 100"
version="1.1"
id="svg5"
xml:space="preserve"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="pawn.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="1.7218764"
inkscape:cx="85.662361"
inkscape:cy="197.16862"
inkscape:window-width="1920"
inkscape:window-height="1002"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
showguides="false" /><defs
id="defs2" /><g
inkscape:label="Vrstva 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(88.929095,-66.473746)"><path
id="path1000"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.54174"
d="m -58.929095,130.47375 v 5 h 10 l -9,11 -21,7 v 13 h 80 v -13 l -21,-7 -9,-11 h 10 v -5 z"
sodipodi:nodetypes="ccccccccccccc" /><circle
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:5.93815"
id="path1011"
cx="-38.929096"
cy="106.47375"
r="20" /></g></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

45
assets/queen.svg Normal file
View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100mm"
height="100mm"
viewBox="0 0 100 100"
version="1.1"
id="svg5"
xml:space="preserve"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="queen.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="2.2746992"
inkscape:cx="144.63451"
inkscape:cy="151.88821"
inkscape:window-width="1920"
inkscape:window-height="1002"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
showguides="false" /><defs
id="defs2" /><g
inkscape:label="Vrstva 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(88.929095,-66.473746)"><path
id="path1000"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.54174"
d="m -58.929095,117.47375 v 7 h 40 v -7 l 15,-16 h -70 z m 0,13 v 5 h 10 l -9,11 -21,7 v 13 h 80 v -13 l -21,-7 -9,-11 h 10 v -5 z M -3.9290951,97.473746 H -73.929095 l 8,-7 h 11 l 12,-5 v -3 h -9 v -8 h 9 v -8 h 8 v 8 h 9 v 8 h -9 v 3 l 12,5 h 11 z"
sodipodi:nodetypes="ccccccccccccccccccccccccccccccccccccccc" /></g></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

45
assets/tower.svg Normal file
View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100mm"
height="100mm"
viewBox="0 0 100 100"
version="1.1"
id="svg5"
xml:space="preserve"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="tower.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="1.8096324"
inkscape:cx="46.418267"
inkscape:cy="168.81882"
inkscape:window-width="1920"
inkscape:window-height="1002"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
showguides="false" /><defs
id="defs2" /><g
inkscape:label="Vrstva 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(88.929095,-66.473746)"><path
id="path1092"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.54174"
d="m -71.929095,76.473884 v 35.999876 l 13,11.99999 h 40 l 13,-11.99999 V 76.473746 h -13 v 11 h -8 v -11 h -24 v 11 h -8.000001 v -11 z m 13,53.999866 v 5 h 10 l -9,11 -21,7 v 13 h 80 v -13 l -21,-7 -9,-11 h 10 v -5 z"
sodipodi:nodetypes="cccccccccccccccccccccccccccc" /></g></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

32
src/Archer.java Normal file
View file

@ -0,0 +1,32 @@
import java.awt.*;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Path2D;
public class Archer extends AbstractPiece {
public Archer(Chessboard c, int x, int y) {
super(c, x, y);
}
@Override
public void paint(Graphics2D g2) {
double[] xObject1 = new double[]{50, 75, 70, 70, 30, 30, 25, 50};
double[] yObject1 = new double[]{0, 21, 57, 64, 64, 57, 21, 0};
double[] xObjectSubtract = new double[]{47, 53, 53, 62, 62, 53, 53, 47, 47, 38, 38, 47, 47};
double[] yObjectSubtract = new double[]{19, 19, 28, 28, 34, 34, 48, 48, 34, 34, 28, 28, 19};
Ellipse2D ellipse = getEllipse(18, 11.412, 64, 51);
Area area = new Area(getStand());
area.add(new Area(getObject(xObject1, yObject1)));
area.add(new Area(ellipse));
area.subtract(new Area(getObject(xObjectSubtract, yObjectSubtract)));
paintObjects(g2, new Shape[]{area});
}
}

View file

@ -11,6 +11,17 @@ public class DrawingPanel extends JPanel {
public DrawingPanel() {
this.setPreferredSize(new Dimension(800, 600));
chessboard = new Chessboard(this);
new Tower(chessboard, 0, 7);
new Horse(chessboard, 1, 7);
new Tower(chessboard, 7, 7);
new Horse(chessboard, 6, 7);
new Queen(chessboard, 4, 7);
new Archer(chessboard, 5, 7);
new Archer(chessboard, 2, 7);
new King(chessboard, 3, 7);
for (int i = 0; i < 8; i++) {
new Pawn(chessboard, i, 6);
}
}
private Chessboard chessboard;

19
src/Horse.java Normal file
View file

@ -0,0 +1,19 @@
import java.awt.*;
public class Horse extends AbstractPiece {
public Horse(Chessboard c, int x, int y) {
super(c, x, y);
}
@Override
public void paint(Graphics2D g2) {
double[] xObject1 = new double[]{21, 62, 82, 82, 70, 30, 30, 44, 41, 30, 15, 14, 28, 21};
double[] yObject1 = new double[]{0, 0, 18, 44, 58, 58, 50, 33, 30, 43, 43, 31, 10, 0};
paintObjects(g2, new Shape[]{getStand(), getObject(xObject1, yObject1)});
}
}

32
src/King.java Normal file
View file

@ -0,0 +1,32 @@
import java.awt.*;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Path2D;
public class King extends AbstractPiece {
public King(Chessboard c, int x, int y) {
super(c, x, y);
}
@Override
public void paint(Graphics2D g2) {
double[] xObject1 = new double[]{18, 27, 34, 43, 50, 57, 66, 73, 82, 70, 70, 30, 30, 18};
double[] yObject1 = new double[]{27, 33, 26, 33, 26, 33, 26, 33, 27, 52, 58, 58, 52, 27};
double[] xObjectClip = new double[]{27, 73, 73, 66, 57, 50, 43, 34, 27, 27};
double[] yObjectClip = new double[]{0, 0, 28, 21, 28, 21, 28, 21, 28, 0};
Path2D objectClip = getObject(xObjectClip, yObjectClip);
Ellipse2D ellipse = getEllipse(30, 6, 40, 40);
Area intersection = new Area(ellipse);
intersection.intersect(new Area(objectClip));
Ellipse2D ellipse2 = getEllipse(44, 0, 12, 12);
intersection.add(new Area(ellipse2));
paintObjects(g2, new Shape[]{getStand(), getObject(xObject1, yObject1), intersection});
}
}

17
src/Pawn.java Normal file
View file

@ -0,0 +1,17 @@
import java.awt.*;
import java.awt.geom.Ellipse2D;
public class Pawn extends AbstractPiece {
public Pawn(Chessboard c, int x, int y) {
super(c, x, y);
}
@Override
public void paint(Graphics2D g2) {
paintObjects(g2, new Shape[]{getStand(), getEllipse(30, 20, 40, 40)});
}
}

22
src/Queen.java Normal file
View file

@ -0,0 +1,22 @@
import java.awt.*;
public class Queen extends AbstractPiece {
public Queen(Chessboard c, int x, int y) {
super(c, x, y);
}
@Override
public void paint(Graphics2D g2) {
double[] xObject1 = new double[]{46, 54, 54, 63, 63, 54, 54, 66, 77, 85, 15, 23, 34, 46, 46, 37, 37, 46, 46};
double[] yObject1 = new double[]{0, 0, 8, 8, 16, 16, 19, 24, 24, 31, 31, 24, 24, 19, 16, 16, 8, 8, 0};
double[] xObject2 = new double[]{15, 85, 70, 70, 30, 30, 15};
double[] yObject2 = new double[]{35, 35, 51, 58, 58, 51, 35};
paintObjects(g2, new Shape[]{getStand(), getObject(xObject1, yObject1), getObject(xObject2, yObject2)});
}
}

20
src/Tower.java Normal file
View file

@ -0,0 +1,20 @@
import java.awt.*;
import java.awt.geom.Path2D;
public class Tower extends AbstractPiece {
public Tower(Chessboard c, int x, int y) {
super(c, x, y);
}
@Override
public void paint(Graphics2D g2) {
double[] xObject1 = new double[]{17, 30, 30, 38, 38, 62, 62, 70, 70, 83, 83, 70, 30, 17, 17};
double[] yObject1 = new double[]{10, 10, 21, 21, 10, 10, 21, 21, 10, 10, 46, 58, 58, 46, 10};
paintObjects(g2, new Shape[]{getStand(), getObject(xObject1, yObject1)});
}
}