Eclipse Client Environment Setup
Overview
This document provides instructions for setting up the Java environment for developing code which controls a ship in the Space Battle Arena (SBA) programming game.
These instructions were prepared for Eclipse Luna Service Release 2 (4.4.2) and above.
Initial Environment Setup
Create a new Java Project in the Package Exploerer:
Make sure to give your Project a name and to select Use project folder as root for sources and class files:
Click Next.
Click on the Libraries tab.
Click on Add External JARs.
Select both the gson-2.2.jar and SpaceBattle.jar which you should have downloaded:
Click Finish
Class Setup
Right-click and add a new Class to your new project:
Give you Ship a Name and select the BasicSpaceship as the Superclass:
Click Finish
Fill in some basics to your Spaceship class:
import java.awt.Color; import ihs.apcs.spacebattle.*; import ihs.apcs.spacebattle.commands.*; public class ExampleShip extends BasicSpaceship { @Override public RegistrationData registerShip(int numImages, int worldWidth, int worldHeight) { return new RegistrationData("Example Ship", new Color(255, 255, 255), 0); } @Override public ShipCommand getNextCommand(BasicEnvironment env) { return new IdleCommand(0.1); } }
Execution Instructions
Note: Do not terminate the program through the Eclipse UI; instead, click in the console window and type 'QUIT' to gracefully close the connection.
Open up your Run Configurations:
Create a new configuration under Java Application:
Select a Main class of ihs.apcs.spacebattle.TextClient:
Click the Arguments tab and enter the IP address of the server and your Java Class name with a space in-between:
e.g. 127.0.0.1 MyFirstShip
Click Apply and Run.
Type 'QUIT' in the Console window to disconnect your ship: