Skip to content

apetenchea/SpaceInvaders

Repository files navigation

Build Status

SpaceInvaders - a multiplayer game made from scratch.

I've always wondered what is going on behind a multiplayer game, so I decided to make one in order to find out! Inspired by the well known classic, up to 3 players may team up in an online battle agains the invaders.

The required Java version is Java 8 or newer.

Building

Using maven:

mvn package

Just compiling the source into .class files:

  1. Go to where the source files are (src/main/java)
  2. Run:
mkdir target
  1. Replace path_to_gson with the path to gson-2.8.0.jar and run::
javac -d target -classpath path_to_gson -sourcepath . spaceinvaders/SpaceInvaders.java

Usage

The game consists of two parts: a client and a server.

Server

Starting up:

java -jar spaceinvaders*.jar server port [verbose]

The script server.sh contains an example of how to start a server on your machine, on port 5412. If you add the verbose argument, the logging is going to be more verbose. Using the .jar file is recommended. Because when running a .jar Java handles resourced differently from when you are running .class files, a small modification in the code is required in the second case. In the class Config, there is a field:

private static final transient Boolean JAR_FILE = true;

This field must be set to false in case the target is not a .jar file.

Client

Starting up:

java -jar spaceinvaders*.jar client [verbose]

The script client.sh contains an example of how to run the client. If you add verbose as an argument, the logging is going to be more verbose. In order to play the game, you must choose an username, how many players your team shall you team have, and then connect to a running server.

Configuration files

  • app.json contains runtime information about the application. In case of a lan party, the lanGame field should be set to true, thus configuring the game to prefer the UDP protocol over TCP.
  • client.json contains the client's configuration.
  • game.json is used to configure the gameplay.
  • resources.json is used to locate resources.

Code

The code follows the Google Java Style Guide and is checked using checkstyle.

Documenation

Documenation is generated using javadoc. The script getDoc.sh handles this.

Credits for the materials used in this game

Icons made by Freepik, Madebyoliver, Roundicons, Alfredo Hernandez from www.flaticon.com are licensed by CC 3.0 BY. Some of the original icons were edited by luciamoga.

Screenshot

Screenshot.png

Releases

No releases published

Packages

No packages published