A LAN multiplayer checkers game with a multi-threaded server, implemented using Java sockets and JavaFX. Done as term project for CSE-108 Object Oriented Programming sessional of BUET.
gameplay.mp4
Sign in, sign up and waiting for opponent
Help, surrender and track record
-
Multi-player checkers between different PCs when with network connection, you can play with two players at the same PC by turning off network.
-
Don’t know rules of checkers? No worries, go to Options → help. Almost every rule is covered there. It also shows all possible moves if you select a piece.
-
Have you become sure that you are going to lose this game? No need to waste time, you have option to surrender.
-
Online track record system which shows how many games you have played on-line and how many games you have won on-line.
-
If any player closes the game before finishing an on-line game, opponent wins automatically.
-
In on-line game, you see the game from you side, if you play using white, you see from white side, if you play using black, you see from black side. White and black are decided automatically from the server while pairing two players.
-
Auto select desired piece when jump is mandatory.
-
Obviously there is option to sign in and sign up to keep track record. Shows your name, opponent’s name and how many pieces have been eaten of each color.
Check java version using: java --version
. If java isn't installed, run sudo apt install default-jre
- javafx sdk isn't shipped together, you have to separately install javafx sdk:
sudo apt install openjfx
. - cd Network-Checkers
- Run server:
java --module-path /usr/share/openjfx/lib --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web -ea -jar out/artifacts/server/server.jar
- Run client:
java --module-path /usr/share/openjfx/lib --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web -ea -jar out/artifacts/client/client.jar
- cd Network-Checkers
- /LOCATION_TO_JDK/bin/java -jar out/artifacts/server/server.jar
- /LOCATION_TO_JDK/bin/java -jar out/artifacts/client/client.jar
Other versions of oracle jdk and openjdk, even openjdk-8 may not work using this method.
- Sockets
- Threads
- JavaFX
- I should've decoupled grid (UI component) and state in GameMain, using either MVC or something like:
new Thread(()->{
while (true) {
Platform.runLater(GameMain::displayState);
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
- I should've separated UI components in Controllers using Controller's initialize() and avoided scene.lookup("#id") completely.