BlueJ 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 BlueJ (3.1.5) and above.
Initial Environment Setup
From the Tools menu select Preferences in the main window:
Click on the Libraries tab.
Click on Add.
Select both the gson-2.2.jar and SpaceBattle.jar which you should have downloaded:
Click OK
Click OK on the warning that pops up:
Close and re-open BlueJ.
Class Setup
Click the New Class... button to add one to your project:
Double-click the new class to bring up the editor and extend BasicSpaceship, like the example below:
import java.awt.Color; import ihs.apcs.spacebattle.*; import ihs.apcs.spacebattle.commands.*; public class ExampleShip extends BasicSpaceship { public static void main(String[] args) { TextClient.run("127.0.0.1", new ExampleShip()); } @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); } }
You should be able to go to Tools -> Compile (Ctrl-K) and have no errors.
Execution Instructions
Note: Do not terminate the program through the BlueJ UI; instead, click in the console window and type 'QUIT' to gracefully close the connection.
Go to your main window and right-click on your class.
Select the main method:
Click OK in the Method Call dialog which appears.
When done, type 'QUIT' in the Console window to disconnect your ship: