Subversion Repositories AndroidProjects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
265 chris 1
package com.gebauz.Bauzoid.app;
2
 
3
import com.badlogic.gdx.ApplicationListener;
4
 
5
/** Base class for applications using Bauzoid engine. */
6
public abstract class BauzoidApp implements ApplicationListener
7
{
8
        protected Game mGame = null;
9
        private long mSystemTimeMs = System.currentTimeMillis();
10
 
11
        public BauzoidApp()
12
        {
13
        }
14
 
15
        @Override
16
        public void create()
17
        {
18
                mGame = new Game();
19
                mGame.init();
20
 
21
                initGame();
22
 
23
                mSystemTimeMs = System.currentTimeMillis();
24
        }
25
 
26
        @Override
27
        public void dispose()
28
        {
29
                exitGame();
30
 
31
                mGame.exit();
32
                mGame = null;
33
        }
34
 
35
        @Override
36
        public void pause()
37
        {
38
                mGame.pause();
39
        }
40
 
41
        @Override
42
        public void resume()
43
        {
44
                mGame.resume();
45
        }
46
 
47
        @Override
48
        public void resize(int w, int h)
49
        {
50
                mGame.resize(w, h);
51
        }
52
 
53
        @Override
54
        public void render()
55
        {
56
                long currentTimeMs = System.currentTimeMillis();
57
                long deltaTimeMs = currentTimeMs - mSystemTimeMs;
58
                mSystemTimeMs = currentTimeMs;
59
 
60
                mGame.update((float)deltaTimeMs / 1000.0f);
61
 
62
                mGame.render();
63
        }
64
 
65
        /** Called after the engine internals have been initialized - this is the point to kick off the initial game state. */
66
        public abstract void initGame();
67
 
68
        /** Called before the engine internals are cleaned up. */
69
        public abstract void exitGame();
70
 
71
        /** Get the instance of the game. */
72
        public Game getGame()
73
        {
74
                return mGame;
75
        }
76
 
77
}