-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseGame.java
More file actions
68 lines (58 loc) · 1.67 KB
/
BaseGame.java
File metadata and controls
68 lines (58 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.ezardlabs.dethsquare.util;
import android.app.Activity;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import com.ezardlabs.dethsquare.GameObject;
import com.ezardlabs.dethsquare.Input;
import com.ezardlabs.dethsquare.R;
import com.ezardlabs.dethsquare.Renderer;
import com.ezardlabs.dethsquare.Screen;
import com.ezardlabs.dethsquare.Time;
public abstract class BaseGame extends Activity {
private GameView gameView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gameView = (GameView) findViewById(R.id.root);
Utils.init(this);
}
@Override
protected void onResume() {
super.onResume();
if (VERSION.SDK_INT >= 14) {
int visibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
if (VERSION.SDK_INT >= 16) {
visibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN;
}
if (VERSION.SDK_INT >= 19) {
visibility |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
}
getWindow().getDecorView().setSystemUiVisibility(visibility);
}
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
gameView.onResume();
}
@Override
protected void onPause() {
super.onPause();
gameView.onPause();
}
public abstract void create();
void update() {
Input.update();
GameObject.updateAll();
Time.frameCount++;
}
void render() {
Renderer.renderAll();
}
void onResize(int width, int height) {
Screen.scale = (float) width / 1920f;
Screen.width = width;
Screen.height = height;
}
}