package com.gebauz.PonPonChun;
import com.gebauz.Bauzoid.app.BauzoidApp;
import com.gebauz.Bauzoid.game.Game.IGameFactory;
import com.gebauz.PonPonChun.PonPonChunCustomServices;
import com.gebauz.PonPonChun.game.GameConsts;
public class PonPonChunApp
extends BauzoidApp
{
private String mFpsString
;
private String mFrameTimeString
;
private float mFpsUpdateTimer = 1.0f
;
public PonPonChunApp
(boolean adsEnabled
)
{
this(adsEnabled,
null);
}
public PonPonChunApp
(boolean adsEnabled, IGameFactory gameFactory
)
{
super("Pon-Pon Chun", adsEnabled, gameFactory
);
}
@
Override
public void initGame
()
{
// Global initializations
mGame.
setCustomServices(new PonPonChunCustomServices
(mGame
));
mGame.
getInput().
setVirtualSize(GameConsts.
VIRTUAL_SCREEN_WIDTH, GameConsts.
VIRTUAL_SCREEN_HEIGHT);
mGame.
getGameStateManager().
setDefaultPackage(this.
getClass().
getPackage().
getName() +
".gamestates");
mGame.
getGameStateManager().
setLoadingScreen(new LoadingScreen
(mGame
));
String initialState = mGame.
getSettings().
getSetting("initstate");
String stateParams = mGame.
getSettings().
getSetting("state_param");
mGame.
getGameStateManager().
switchTo(initialState, stateParams
);
//mGame.getGameStateManager().switchTo(com.gebauz.PonPonChun.gamestates.EndlessState.class, "");
// Global sounds.
mGame.
getAudio().
newManagedSound("data/sounds/menu_push.wav");
mGame.
getAudio().
newManagedSound("data/sounds/menu_click.wav");
mGame.
getAudio().
newManagedSound("data/sounds/menu_confirm.wav");
mFpsString =
String.
format("%.2ffps", mGame.
getFps());
mFrameTimeString =
String.
format("%.4fms", mGame.
getFrameTime());
}
@
Override
public void exitGame
()
{
}
@
Override
public void render
()
{
super.
render();
// TODO: put this in engine part
if (mFpsUpdateTimer
> 0.0f
)
{
mFpsUpdateTimer -= mGame.
getDeltaTime();
if (mFpsUpdateTimer
<= 0.0f
)
{
mFpsString =
String.
format("%.2ffps", mGame.
getFps());
mFrameTimeString =
String.
format("%.4fms", mGame.
getFrameTime());
mFpsUpdateTimer = 1.0f
;
}
}
PonPonChunCustomServices.
getInstance().
getFont().
drawText(mFpsString, GameConsts.
VIRTUAL_SCREEN_WIDTH -
100,
30, GameConsts.
WHITE_COLOR);
PonPonChunCustomServices.
getInstance().
getFont().
drawText(mFrameTimeString, GameConsts.
VIRTUAL_SCREEN_WIDTH -
100,
50, GameConsts.
WHITE_COLOR);
}
}