Space Battle Arena

A Programming Game in Java for AP CS Students.

Download Client Jar Java Docs Download Server (Windows) View on GitHub

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

  1. 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);
        }
    }
    
  2. Adjust Workspace Classpath under Settings -> PATH/CLASSPATH -> Workspace:

    Classpath Settings

  3. Add the gson-2.2.jar and SpaceBattle.jar under the PATH -> CLASSPATHS tab using the New button:

    Jars in Classpath

  4. 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.

  1. Compile and run your class as normal.

  2. Type 'QUIT' in the output window to disconnect your ship:

    Output Window