Giter Site home page Giter Site logo

graziaferrara / battleship Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5.58 MB

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.

Java 100.00%
battleship battleship-game client client-server server udp

battleship's Introduction

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)

battleship's People

Contributors

graziaferrara avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.