Coverage Summary for Class: Constants (com.mygdx.utils)
Class |
Class, %
|
Method, %
|
Line, %
|
Constants |
100%
(1/1)
|
33.3%
(1/3)
|
59.3%
(16/27)
|
1 package com.mygdx.utils;
2
3 import com.badlogic.gdx.Gdx;
4 import com.badlogic.gdx.math.Vector2;
5 import com.badlogic.gdx.math.Vector3;
6
7 /**
8 * creates game constants and is updated when appropriate (I know some aren't technically constants)
9 */
10 public final class Constants {
11 public static int SCREEN_WIDTH;
12 public static int SCREEN_HEIGHT;
13 public static boolean FULLSCREEN;
14 public static float ASPECT_RATIO;
15 public static int VIEWPORT_HEIGHT;
16 public static int VIEWPORT_WIDTH;
17 public static int HALF_VIEWPORT_HEIGHT;
18 public static int HALF_VIEWPORT_WIDTH;
19 public static Vector2 DIMENSIONS;
20 public static Vector2 HALF_DIMENSIONS;
21 public static String VIEWPORT_TITLE;
22 public static float PHYSICS_TIME_STEP;
23 public static final float ZOOM = 2.15f;
24 public static final boolean VSYNC = true;
25 public static final float BUILDING_SCALE = 1.5f;
26
27 public static float TILE_SIZE;
28
29 public static Vector3 BACKGROUND_COLOUR;
30
31 public static String OPERATING_SYSTEM;
32
33 /**
34 * Create constants needed so it can properly source screen dimensions
35 */
36 public static void INIT_CONSTANTS() {
37 // FULLSCREEN = !Boolean.parseBoolean(System.getProperty("windowed"));
38 FULLSCREEN = false;
39 try {
40 SCREEN_WIDTH = Gdx.graphics.getWidth();
41 SCREEN_HEIGHT = Gdx.graphics.getHeight();
42 } catch (Exception e) {
43 SCREEN_WIDTH = 1920;
44 SCREEN_HEIGHT = 1080;
45 }
46 ASPECT_RATIO = !FULLSCREEN ? 1.0f : (float) SCREEN_WIDTH / (float) SCREEN_HEIGHT;
47 VIEWPORT_HEIGHT = !FULLSCREEN ? 800 : SCREEN_HEIGHT;
48 VIEWPORT_WIDTH = !FULLSCREEN ? (int) (ASPECT_RATIO * VIEWPORT_HEIGHT) : SCREEN_WIDTH;
49 HALF_VIEWPORT_HEIGHT = VIEWPORT_WIDTH / 2;
50 HALF_VIEWPORT_WIDTH = VIEWPORT_HEIGHT / 2;
51 DIMENSIONS = new Vector2(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
52 HALF_DIMENSIONS = new Vector2(HALF_VIEWPORT_WIDTH, HALF_VIEWPORT_HEIGHT);
53 VIEWPORT_TITLE = "Pirate Game";
54 BACKGROUND_COLOUR = new Vector3(0.0f, 0.0f, 0.0f);
55 PHYSICS_TIME_STEP = 1.0f / 60.0f;
56
57 OPERATING_SYSTEM = System.getProperty("os.name");
58
59 TILE_SIZE = 32;
60 }
61
62 /**
63 * Update viewport data on resize
64 *
65 * @param x new dim x
66 * @param y new dim y
67 */
68 public static void UPDATE_VIEWPORT(int x, int y) {
69 VIEWPORT_HEIGHT = y;
70 VIEWPORT_WIDTH = x;
71 ASPECT_RATIO = (float) SCREEN_WIDTH / (float) SCREEN_HEIGHT;
72 HALF_VIEWPORT_HEIGHT = VIEWPORT_HEIGHT / 2;
73 HALF_VIEWPORT_WIDTH = VIEWPORT_WIDTH / 2;
74 DIMENSIONS = new Vector2(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
75 HALF_DIMENSIONS = new Vector2(HALF_VIEWPORT_WIDTH, HALF_VIEWPORT_HEIGHT);
76 }
77 }