Contents

Overview

The class project has three major components: the input client, the Stratagus game engine and the Battle of Survival data files, and the Visual Analytics application and its data files. Stratagus and Visual Analytics are already provided for you, but you may modify them as you see fit. You will need to implement your own input client, or clients, in order to develop your interaction technique.

Input Client

Your input client, or clients, is where you will generate input events and send them over the network to either Stratagus or Visual Analytics. Each of these applications support mouse and keyboard input only, so you will need to translate all actions in your input client to a mouse or keyboard event. If for some reason your technique cannot be mapped to keyboard or mouse input, you will be responsible for changing the application in such a way that your technique is supported.

For both applications, actions must be translated to SDL events. To shield you from most of the gory details, we have developed an InputClient class that you may use in your input clients. The InputClient class has the following interface:

class InputClient
{
public:
	InputClient(char* hostname, int port);
	~InputClient();
	void BuildMouseButtonDown(int button);
	void BuildMouseButtonUp(int button);
	void BuildMouseButtonDown(int button, int x, int y);
	void BuildMouseButtonUp(int button, int x, int y);
	void BuildMouseMotion(int x, int y);
	void BuildKeyDown(SDLKey key);
	void BuildKeyUp(SDLKey key);
	void SendEvents();
};

The InputClient constructor takes hostname and a port. The hostname should almost always be gigapixel.cs.vt.edu and the port should be in the range 15000-15010.

BuildMouseButtonDown and BuildMouseButtonUp take a button code and optionally an X and Y location where the mouse was pressed or released. The X and Y parameters are just for convenience. The same effect could be achieved by composing BuildMouseMotion with BuildMouseButtonDown and BuildMouseButtonUp. The resulting event is placed on a queue.

BuildMouseMotion takes an X and Y location that the mouse was moved to. The resulting event is placed on a queue.

BuildKeyDown and BuildKeyUp take the key code of the button that was pressed. The resulting event is placed on a queue.

SendEvents transmits events to the server in the order that they were added to the queue.

The code repository has a few examples of using this class to implement simple variations on the mouse and keyboard interaction technique.

Stratagus/Battle of Survival

We managed to modify the stratagus game engine to not only poll the SDL event queue, but to also poll the network for SDL events. This was the simplest and most elegant way to create an interaction framework for the game in the amount of time we had. If it is impossible for you to translate your interaction technique into mouse and keyboard events, then you will need to make modifications to the game engine. Depending on the modifications, this may or may not be extremely difficult. For example, a multi-cursor modification would fall under the extremely difficult category. If your input client needs to have access to some information about the state of the game, you will need to find the part of the engine that deals with that state, serialize it, and send it over the network. This is not terribly difficult and Mike should be able to help you. If you need to send information in addition to the SDL event over the network, this is easy, and again, Mike can help you.

The following table details which keyboard buttons are bound to which game commands by default. Most of these bindings can be modified in the Battle of Survival script files if necessary.

Keyboard Bindings
Cancel Commands
Cancel
SDLK_ESCAPE
Cancel Upgrade
SDLK_ESCAPE
Cancel Build
SDLK_ESCAPE
Cancel Train Unit
SDLK_ESCAPE
Unit Commands
Unload
SDLK_u
Move
SDLK_m
Stop
SDLK_s
Attack
SDLK_a
Patrol
SDLK_p
Stand Ground
SDLK_t
Resource Commands
Repair
SDLK_r
Harvest
SDLK_h
Return Goods
SDLK_g
Build Commands
Build
SDLK_b
Vault
SDLK_a
Generator
SDLK_g
Training Camp
SDLK_c
Development Yard
SDLK_d
Research Facility
SDLK_r
Hospital
SDLK_h
Vehicle Factory
SDLK_v
Missile Silo
SDLK_m
Vault Units
Engineer
SDLK_e
Training Camp Units
Assault
SDLK_a
Grenadier
SDLK_g
Bazoo
SDLK_b
Hospital Units
Medic
SDLK_m
Vehicle Factory Units
APC
SDLK_a
Harvestor
SDLK_h
Research Facility Commands
Explosives Level 1
SDLK_e
Explosives Level 2
SDLK_e
Drill Level 1
SDLK_d
Drill Level 2
SDLK_d
Void
SDLK_v
Building Commands
Harvest/Mine
SDLK_h
Move
SDLK_n
Stop
SDLK_c
Attack
SDLK_i
Special Unit Commands
Heal (medic only)
SDLK_b
Nuke (missile silo only)
SDLK_n
Group Commands (where {#} is a number between 0 and 9)
Make Group
SDLK_RCTRL (or SDLK_LCTRL) + SDLK_{#}
Add to Group
SDLK_RSHIFT (or SDLK_LSHIFT) + SDLK_{#}
Add to Other Group
SDLK_RALT (or SDLK_LALT) + SDLK_{#}
Selection Commands (where {#} is a number between 0 and 9)
Select Group
SDLK_{#}
Select None
SDLK_CARET
Other
Pause
SDLK_RCTRL (or SDLK_LCTRL) + SDLK_p or SDLK_PAUSE
Help Menu
SDLK_RALT (or SDLK_LALT) + SDLK_h
Quit Game
SDLK_RALT (or SDLK_LALT) + SDLK_x
Quit to Menu
SDLK_RALT (or SDLK_LALT) + SDLK_q

Stratagus uses distributed textures to improve performance of the application. The way that this works is the application is ran once to distribute the textures and then ran again to read the textures. To run the game in distributed mode, use:

    ./runbos distribute

To run the game in read mode, use:

    ./runbos

Visual Analytics

The visual analytics application also uses SDL mouse and keyboard events. This was not strictly necessary, but we chose to implement it this way to make interaction techniques as portable as possible between the two applications.