jGRASP 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 jGRASP 1.8 and above.
Initial Environment Setup
Create a Spaceship class:
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); } }
Adjust Workspace Classpath under Settings -> PATH/CLASSPATH -> Workspace:
Add the gson-2.2.jar and SpaceBattle.jar under the PATH -> CLASSPATHS tab using the New button:
Save and Compile your class.
Execution Instructions
Note: Do not terminate the program through the jGRASP UI; instead, click in the console window and type 'QUIT' to gracefully close the connection.
Compile and run your class as normal.
Type 'QUIT' in the output window to disconnect your ship: