graziaferrara / Battleship

This project is a JavaFX implementation of the Battleship game that uses UDP for communication between a server and multiple clients. A GUI is provided for the users to play.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Battleship

This project is a JavaFX implementation of the Battleship game that uses UDP for communication between a server and multiple clients.

  • Each user is identified by a unique username, and the server refuses connections if the username is already logged in.
  • The game server creates a game table for every two clients who connect before starting a game.
  • After joining a table, each player is able to specify the locations of their ships as points on the game board.
  • There are five ships of different dimension: Aircraft Carrier(5), Battleship(4), Destroyer(3), Submarine(3), and Patrol Boat(2).
  • Once both players have placed their ships, the game starts.
  • Each player inputs a coordinate to attack the opponent's ships.
  • The server sends a message to each player indicating whether they hit or missed the enemy's ship.
  • The game boards are updated after each turn.
  • The game continues until one player destroys all of the opponent's ships.


To run the project in the Eclipse IDE make sure to:
  • install the package e(fx)clipse from the marketplace (Help > Eclipse Marketplace), or if you have one of the more recent Java versions, it's better to download its nightly version directly from their repository to avoid the bug verifying when creating a FXML document
  • download the JavaFX SDK (I used the 21) here
  • in Preferences > JavaFX set the path to the lib folder of the SDK
  • in Preferences > User Libraries create a new library (it's sufficient that it contains the jars from the lib folder of the SDK)
  • right click on the project and in Build Path > Configure BuildPath > Libraries > Modulepath add the just created library
  • during the execution, in Run Configurations > Arguments > VM arguments, insert --module-path="/Library/Frameworks/javafx-sdk-21/lib" --add-modules=javafx.controls,javafx.fxml putting your path to the SDK,
  • to avoid problems when running, uncheck the option "Use the -XstartOnFirstThread argument when launching with SWT" (for both the server and the client)

About

This project is a JavaFX implementation of the Battleship game that uses UDP for communication between a server and multiple clients. A GUI is provided for the users to play.


Languages

Language:Java 100.0%