hehe, well, I have an interface called GraphicalSynchronizer that contains all the methods JGN needs to communicate with the graphical engine. All that creating an engine wrapper takes is implementing that interface specific for the engine. I just released another one for GTGE. So currently I support jME, jME-Physics, Swing/AWT, and GTGE. I glanced at Xith last night actually but didnāt get around to doing the implementation.
For example, the source for my reference Swing implementation:
/**
* This is an example implementation of the GraphicalController for use
* with Swing. The objects specified are Components.
*
* @author Matthew D. Hicks
*/
public class SwingGraphicalController implements GraphicalController<Component> {
public void applySynchronizationMessage(SynchronizeMessage message, Component component) {
Synchronize2DMessage m = (Synchronize2DMessage)message;
component.setBounds((int)m.getPositionX(), (int)m.getPositionY(), 50, 50);
}
public SynchronizeMessage createSynchronizationMessage(Component component) {
Synchronize2DMessage message = new Synchronize2DMessage();
message.setPositionX(component.getX());
message.setPositionY(component.getY());
return message;
}
public float proximity(Component component, short playerId) {
return 1.0f;
}
public boolean validateMessage(SynchronizeMessage message, Component component) {
return true;
}
}
Then in your code you simply register the Component objects in the way you want to use them with their priority and synchronization information gets sent for you and applied. I havenāt added anything for dead-reckoning or anything yet, but intend to in a future version. The proximity method can be utilized to specify how close the object is to you. If the proximity is 1.0f the component gets synchronized at the standard rate, but as it approaches 0.0f the delay increases (meaning the object is further away and doesnāt need to be synchronized as frequenty). When the value is 0.0f no update is sent because it is considered to be outside of range of your player. The validateMessage gives the game the opportunity to validate the message to verify it before it is applied. This is useful for a server to be able to determine if a player is either too far out of sync to accept the update or is trying to cheat. Further, if it returns false it is not only not applied, but it also sends a message back to the sender telling them to update the position of that object to where it really should be.
There is still a lot I intend to do with this, but it does offer a lot already.