DEADSOFTWARE

Add more GameWorld methods
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / GameScreen.java
1 package ru.deadsoftware.cavedroid;
3 import com.badlogic.gdx.Gdx;
4 import com.badlogic.gdx.Screen;
5 import ru.deadsoftware.cavedroid.game.GameItems;
6 import ru.deadsoftware.cavedroid.game.GameProc;
7 import ru.deadsoftware.cavedroid.game.GameSaver;
8 import ru.deadsoftware.cavedroid.menu.MenuRenderer;
9 import ru.deadsoftware.cavedroid.misc.*;
11 public class GameScreen implements Screen {
13 public static int FPS;
14 public static boolean SHOW_DEBUG = true;
15 public static boolean SHOW_MAP = false;
16 public static int NEW_GAME_MODE = 0;
18 public static GameProc GP;
20 private Renderer renderer;
21 private MenuRenderer menuRenderer;
23 public GameScreen() {
24 Assets.load();
25 GameItems.load();
26 menuRenderer = new MenuRenderer(CaveGame.TOUCH ? 320 : 480);
27 renderer = menuRenderer;
28 Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer));
29 }
31 public static float getWidth() {
32 return Gdx.graphics.getWidth();
33 }
35 public static float getHeight() {
36 return Gdx.graphics.getHeight();
37 }
39 private void game(float delta) {
40 GP.update(delta);
41 }
43 private void menu() {
44 }
46 @Override
47 public void show() {
48 }
50 @Override
51 public void render(float delta) {
52 FPS = (int) (1 / delta);
53 switch (CaveGame.STATE) {
54 case GAME_PLAY:
55 case GAME_CREATIVE_INV:
56 game(delta);
57 break;
59 case MENU_MAIN:
60 menu();
61 break;
63 case NEW_GAME:
64 GP = new GameProc();
65 GP.initGame(NEW_GAME_MODE);
66 renderer = GP.renderer;
67 Gdx.input.setInputProcessor(new InputHandlerGame());
68 CaveGame.STATE = AppState.GAME_PLAY;
69 break;
71 case LOAD_GAME:
72 GP = GameSaver.load();
73 renderer = GP.renderer;
74 Gdx.input.setInputProcessor(new InputHandlerGame());
75 CaveGame.STATE = AppState.GAME_PLAY;
76 break;
78 case SAVE_GAME:
79 GameSaver.save(GP);
80 CaveGame.STATE = AppState.MENU_MAIN;
81 break;
83 case GOTO_MENU:
84 GP.dispose();
85 menuRenderer = new MenuRenderer(CaveGame.TOUCH ? 320 : 480);
86 renderer = menuRenderer;
87 Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer));
88 break;
89 }
90 renderer.render();
91 }
93 @Override
94 public void resize(int width, int height) {
95 switch (CaveGame.STATE) {
96 case MENU_MAIN:
97 menuRenderer = new MenuRenderer(CaveGame.TOUCH ? 320 : 480);
98 Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer));
99 renderer = menuRenderer;
100 break;
101 case GAME_PLAY:
102 case GAME_CREATIVE_INV:
103 GP.resetRenderer();
104 renderer = GP.renderer;
105 break;
109 @Override
110 public void pause() {
114 @Override
115 public void resume() {
119 @Override
120 public void hide() {
124 @Override
125 public void dispose() {