One approach I was considering was to having 2 separate Projects each with using separate Application classes and each of these projects would reference a "library" project which contains the main code(i.e. Activity and Views, etc.) and assets. It's not a bad idea, other than there is the potential that the code diverges (from one version to the other) and then you have a perfectly good running debug version (which gets the majority of iterations) and a relatively "untested" production version.
The approach I am taking now is to have the "editors" introduce themselves into the code at bootstrap and this will take place if the Development project is built in the classpath. So there is only 1 place in which the Production (running) version of the code differs from the debug version of the code... here is the (current) wiring code for the "production" version.
public class BeaconDependencyProvider implements IBeaconDependencyProvider {
GameRenderer gr;
GameTiltListenerConfig tiltConfig;
GameTiltListener tilt;
GameMapLoader mapLoader;
GameState gameState;
Simulation sim;
@Override
public void setUp(Application application) {
gr = new GameRenderer (new GameMapRenderer(new SolidColorTileRenderer(), new BallRenderer()));
tiltConfig = new GameTiltListenerConfig();
tilt = new GameTiltListener(tiltConfig);
mapLoader = new GameMapLoader(application);
gameState = new GameState();
sim = new Simulation (mapLoader, tilt, gameState);
}
The Debug version is "wired" together differently:
/** Provides the debug dependencies for Beacon */
public class BeaconDebugDependencyProvider implements IBeaconDependencyProvider {
/** All Editors for the Game */
public CompositeEditor ce;
IGameRenderer gr;
GameTiltListenerConfig tiltConfig;
GameTiltListener tilt;
IGameMapLoader mapLoader;
GameState gameState;
Simulation sim;
public void setUp(Application application) {
Log.e("BeaconDebugModule", "Configuring Dependencies");
TileColorPalette tcp = new TileColorPalette();
BallRenderer br = new BallRenderer();
SolidColorTileRenderer sctr = new SolidColorTileRenderer(tcp);
GameMapRenderer gmr = new GameMapRenderer(sctr, br);
GameRenderer sr = new GameRenderer (gmr);
this.gr = sr;
GameTiltListenerConfig tiltConfig = new GameTiltListenerConfig();
tilt = new GameTiltListener(tiltConfig);
GameMapEditor gme = new GameMapEditor();
mapLoader = new EditableGameMapLoader(application, gme);
gameState = new GameState();
sim = new Simulation (mapLoader, tilt, gameState);
ce = new CompositeEditor();
FieldEditor tcpe = new FieldEditor(tcp);
GameTiltConfigEditor gte = new GameTiltConfigEditor(tiltConfig);
FieldEditor gse = new FieldEditor(gameState);
ce.addEditor ("tiltConfig",gte);
ce.addEditor("tileColorPalette", tcpe);
ce.addEditor("gameState", gse);
ce.addEditor("gameMap", gme);
}
All the Editor code does not exist in the production distro, in addition, none of the overhead of creating and wiring the editors is incurred by the main game while running.
One aspect I need to explore is forcing a refresh of the screen, for instance, at the moment my gameMap class is created and stored, and each time the frame is drawn, the cached bitmap is presented on the screen. I need a "generic" avenue for forcing the game to realize that a recently loaded asset is dirty, and it needs to trigger a refresh to cause the screen to re-render.
No comments:
Post a Comment