Java Game API
At minimum, only two API classes are necessary: SgState and SgStub.
The SgState class describes the state of the SymGym controller at any given moment. It contains information about position, velocity, and resistance of each limb and also the state of each of SymGym’s eight buttons. The state can be obtained by using SgStub class, see below.
SgState’s “getter” methods follow this convention:
For example, in order to get left leg’s velocity, use this:
nt v = getLeftLegVelocity();
Position and resistance values are integers with a range from 0 to 99, velocity can be from -99 to +99.
Similarly, this is the pattern to inquire about the state of buttons (true means ‘pressed’):
For example, in order to check on right sub-trigger button, use this:
boolean pressed = isRightSubTrigger();
SgStub is a communication stub class for all SymGym operations. The stub is initialized by its constructor:
public SgStub(Context context, final String apiKey)
where context is of the currently executing Activity or Fragment and apiKey is a special string provided for your application by SymGym development operations. It is used to associate your game with the payments you will receive and to authenticate your game to the SymGym controller.
After stub is initialized, it can be used to obtain SymGym’s state and set its resistance level:
SgStub stub = new SgStub(this, "apikeystring"); SgState state = stub.getState(); stub.setResistanceAll(55);
SgStub has convenience methods to set resistance. The resistance parameter is an integer with a range from 0 to 99:
public void setResistance(final int leftLeg, final int rightLeg, final int leftArm, final int rightArm) public void setResistanceLeftLeg (int resist) public void setResistanceRightLeg(int resist) public void setResistanceLeftArm (int resist) public void setResistanceRightArm(int resist) public void setResistanceArms (int resist) public void setResistanceLegs (int resist) public void setResistanceAll (int resist)