VS Code 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 VS Code 1.39 and above.
Initial Java Setup
If you already have Java installed and the JAVA_HOME environment variable set, proceed to the next section.
Install the Java Extension Pack in VS Code:
vscjava.vscode-java-pack
It should open the Configure Java Runtime after installed, if not use F1 to get the command: "Java: Configure Java Runtime"
See if it has detected your Java installation or not:
If not, select "OpenJDK 8" and click the "Download" button.
VS Code will prompt if you want to open the link, click the "Open Link" button.
Download and Run the MSI installer for OpenJDK from your browser.
Proceed through the installer to the "Custom Setup" page and change the JAVA_HOME option in the dropdown to be installed:
Click Next after changing the setting and click Install.
Click the Reload Window button in VS Code beneath the Download button you used.
Initial Environment Setup
Bootstrap the project by using git to clone our quickstart project:
git clone https://github.com/Mikeware/SBA-VSCode-Java.git
This includes all the client library dependencies as well as project and classpath files setup for you.
Class Setup
Open up the ExampleShip.java file under the src directory.
It should look something like this:
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); } }
Execution Instructions
Note: Do not terminate the program through the VS Code UI; instead, click in the Terminal window and type 'QUIT' to gracefully close the connection.
In your ExampleShip.java file, edit the IP address in the call to TextClient.run to point it to the location of your server.
TextClient.run("127.0.0.1", new ExampleShip());
Hit F5 to launch the ship.
You may need to allow the Java client access through the Windows Firewall:
This will be a one-time operation.
Type 'QUIT' in the Terminal pane to disconnect your ship:
Note: You will NOT see the output of your typing until you hit enter.