ShafinKhadem / Checkers-LAN-multiplayer

Our term project of Level 1 term 2 Multiplayer checkers using javafx client & java multithreaded server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Network-Checkers

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

gameplay.mp4

Screenshots of game

Sign in, sign up and waiting for opponent

Sign in, sign up and waiting for opponent

Help, surrender and track record options

Help, surrender and track record

Key features

  1. Multi-player checkers between different PCs when with network connection, you can play with two players at the same PC by turning off network.

  2. 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.

  3. Have you become sure that you are going to lose this game? No need to waste time, you have option to surrender.

  4. Online track record system which shows how many games you have played on-line and how many games you have won on-line.

  5. If any player closes the game before finishing an on-line game, opponent wins automatically.

  6. 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.

  7. Auto select desired piece when jump is mandatory.

  8. 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.

How to run in linux

Check java version using: java --version. If java isn't installed, run sudo apt install default-jre

Using openjdk-11

  • 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

Using oracle jdk 8

  • 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.

Used technologies

  • Sockets
  • Threads
  • JavaFX

Biggest lessons

  • 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.

Useful links

About

Our term project of Level 1 term 2 Multiplayer checkers using javafx client & java multithreaded server


Languages

Language:Java 93.4%Language:HTML 6.6%