Rev 213 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 200 | chris | 1 | package com.gebauz.Bauzoid.app; |
| 2 | |||
| 3 | import com.gebauz.Bauzoid.gamestates.GameStateManager; |
||
| 4 | import com.gebauz.Bauzoid.graphics.Graphics; |
||
| 5 | |||
| 6 | /** Root object for the game. Manages game-global objects, acts as the root of the game graph, and kicks off update and render calls. |
||
| 7 | * |
||
| 8 | * This is the parent class for the following subsystems: |
||
| 9 | * - GameStateManager: Root object for game states. |
||
| 10 | * - Graphics: Root object for all graphics objects |
||
| 11 | * - Audio: Root object for all audio objects |
||
| 12 | * - .. |
||
| 13 | * |
||
| 14 | * It also offers convenient access to the Android application's Context |
||
| 15 | */ |
||
| 16 | public class Game |
||
| 17 | { |
||
| 18 | private GameStateManager mGameStateManager = null; |
||
| 19 | |||
| 20 | private Graphics mGraphics = null; |
||
| 21 | // private Audio mAudio = null; |
||
| 22 | |||
| 23 | /** Constructor. */ |
||
| 24 | public Game() |
||
| 25 | { |
||
| 26 | // Set the context to use for engine exceptions |
||
| 27 | |||
| 28 | mGameStateManager = new GameStateManager(this); |
||
| 29 | |||
| 30 | mGraphics = new Graphics(this); |
||
| 31 | // mAudio = new Audio(this); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** Called for game-global initialization. */ |
||
| 35 | public void init() |
||
| 36 | { |
||
| 226 | chris | 37 | mGraphics.init(); |
| 200 | chris | 38 | mGameStateManager.init(); |
| 39 | } |
||
| 40 | |||
| 41 | /** Called for game-global destruction. */ |
||
| 42 | public void exit() |
||
| 226 | chris | 43 | { |
| 200 | chris | 44 | mGameStateManager.exit(); |
| 226 | chris | 45 | mGraphics.exit(); |
| 200 | chris | 46 | } |
| 47 | |||
| 48 | /** Update game logic state. */ |
||
| 49 | public void update(float deltaTime) |
||
| 50 | { |
||
| 51 | mGameStateManager.update(deltaTime); |
||
| 52 | // mAudio.update(deltaTime); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** Render game. */ |
||
| 56 | public void render() |
||
| 57 | { |
||
| 58 | mGameStateManager.render(); |
||
| 59 | // mAudio.render(); |
||
| 60 | } |
||
| 61 | |||
| 62 | /** Called when the surface dimensions have changed. */ |
||
| 213 | chris | 63 | public void resize(int w, int h) |
| 200 | chris | 64 | { |
| 65 | mGraphics.updateSurfaceDimensions(w, h); |
||
| 66 | mGameStateManager.onSurfaceChanged(w, h); |
||
| 67 | } |
||
| 68 | |||
| 69 | /** Called when the OpenGL Context is about to be destroyed. */ |
||
| 213 | chris | 70 | public void pause() |
| 200 | chris | 71 | { |
| 72 | mGraphics.onSurfaceLost(); |
||
| 73 | } |
||
| 74 | |||
| 75 | /** Called when the OpenGL Context has been recreated after onSurfaceLost(). */ |
||
| 213 | chris | 76 | public void resume() |
| 200 | chris | 77 | { |
| 78 | mGraphics.onSurfaceRecreated(); |
||
| 79 | } |
||
| 80 | |||
| 81 | /** Get the main graphics object. */ |
||
| 82 | public final Graphics getGraphics() |
||
| 83 | { |
||
| 84 | return mGraphics; |
||
| 85 | } |
||
| 86 | |||
| 87 | /** Get the main audio object. */ |
||
| 88 | /* public final Audio getAudio() |
||
| 89 | { |
||
| 90 | return mAudio; |
||
| 91 | }*/ |
||
| 92 | |||
| 93 | /** Get the GameStateManager. */ |
||
| 94 | public final GameStateManager getGameStateManager() |
||
| 95 | { |
||
| 96 | return mGameStateManager; |
||
| 97 | } |
||
| 98 | |||
| 99 | } |