1 package ru
.deadsoftware
.cavedroid
;
3 import com
.badlogic
.gdx
.Application
;
4 import com
.badlogic
.gdx
.Game
;
5 import com
.badlogic
.gdx
.Gdx
;
6 import ru
.deadsoftware
.cavedroid
.game
.GameScreen
;
7 import ru
.deadsoftware
.cavedroid
.misc
.Assets
;
8 import ru
.deadsoftware
.cavedroid
.misc
.utils
.AssetLoader
;
10 import javax
.annotation
.Nullable
;
12 public class CaveGame
extends Game
{
14 private static final String TAG
= "CaveGame";
16 public static final String VERSION
= "alpha 0.5.2";
18 private final MainConfig mMainConfig
;
19 private final MainComponent mMainComponent
;
20 private final AssetLoader mAssetLoader
;
22 private final String mGameFolder
;
23 private final boolean mTouch
;
24 private boolean mDebug
;
27 private final String mAssetsPackPath
;
29 public CaveGame(String gameFolder
, boolean touch
, @Nullable String assetsPackPath
) {
30 mGameFolder
= gameFolder
;
32 mAssetsPackPath
= assetsPackPath
;
34 mMainComponent
= DaggerMainComponent
.builder().caveGame(this).build();
36 mMainConfig
= mMainComponent
.getMainConfig();
37 mAssetLoader
= mMainComponent
.getAssetLoader();
40 public void setDebug(boolean debug
) {
44 private void initConfig() {
45 int width
= mTouch ?
320 : 480;
46 int height
= (int) (width
* ((float) Gdx
.graphics
.getHeight() / Gdx
.graphics
.getWidth()));
48 mMainConfig
.setMainComponent(mMainComponent
);
49 mMainConfig
.setGameFolder(mGameFolder
);
50 mMainConfig
.setTouch(mTouch
);
51 mMainConfig
.setWidth(width
);
52 mMainConfig
.setHeight(height
);
53 mMainConfig
.setShowInfo(mDebug
);
54 mMainConfig
.setAssetsPackPath(mAssetsPackPath
);
57 Gdx
.app
.setLogLevel(Application
.LOG_DEBUG
);
59 Gdx
.app
.setLogLevel(Application
.LOG_ERROR
);
63 public void newGame(int gameMode
) {
64 GameScreen gameScreen
= mMainComponent
.getGameScreen();
65 gameScreen
.newGame(gameMode
);
66 setScreen(gameScreen
);
69 public void loadGame() {
70 GameScreen gameScreen
= mMainComponent
.getGameScreen();
71 gameScreen
.loadGame();
72 setScreen(gameScreen
);
75 public void quitGame() {
79 setScreen(mMainComponent
.getMenuScreen());
83 public void create() {
84 Gdx
.app
.log(TAG
, mGameFolder
);
85 Gdx
.files
.absolute(mGameFolder
).mkdirs();
87 Assets
.load(mAssetLoader
);
88 setScreen(mMainComponent
.getMenuScreen());
92 public void dispose() {