Space Battle Arena

A Programming Game in Java for AP CS Students.

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

VS Code C# Client Environment Setup

Overview

This document provides instructions for setting up the C# environment for developing code which controls a ship in the Space Battle Arena (SBA) programming game.

This initial C# support was added by the community and is built by them, it is not yet officially supported by Mikeware, use at your own risk. See Issue #162

These instructions were prepared for VS Code 1.39 and above.

Initial C# Setup

These instructions were tested with .NET Core 3.0

  1. Download and install the .NET 3 Core SDK, if you haven't already.

  2. Open VS Code and Install the C# extension: ms-vscode.csharp

Initial Environment Setup

  1. Create a new folder and open it in VS Code.

  2. Open the Terminal and type:

     dotnet new console
    
  3. Then add the SBA NuGet package:

     dotnet add package SBA_Client.Net
    

Class Setup

  1. Open up the Program.cs file.

  2. Modify it to look like this:

    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using SpaceBattleArena;
    
    namespace APCS
    {    
        class Program
        {
            static void Main(string[] args)
            {
                TextClient<BasicGameInfo>.run("127.0.0.1", new MyShip(), 2012);
            }
        }
    
        class MyShip : BasicSpaceship 
        {
            override public RegistrationData registerShip(int numImages, int worldWidth, int worldHeight)
            {
                return new RegistrationData("Example Ship", Color.White, 0);
            }
    
            override public ShipCommand getNextCommand(BasicEnvironment env)
            {
                return new IdleCommand(1);
            }
        }
    }
    

Execution Instructions

Note: Do not terminate the program through the VS Code UI; instead, click in the Terminal window and use 'Ctrl+C' to gracefully close the connection.

  1. In your Program.cs file, edit the IP address in the call to TextClient.run to point it to the location of your server.

     TextClient<BasicGameInfo>.run("127.0.0.1", new MyShip(), 2012);
    
  2. Open the Terminal and use:

     dotnet run
    

    To start the application.

  3. Type 'Ctrl+C' in the Terminal pane to disconnect your ship.