Coverage Summary for Class: Constants (com.mygdx.utils)

Class Class, % Method, % Line, %
Constants 100% (1/1) 100% (3/3) 88.9% (24/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  /** 12  * Create constants need so it can properly source screen dimensions 13  */ 14  public static void INIT_CONSTANTS() { 15  // FULLSCREEN = !Boolean.parseBoolean(System.getProperty("windowed")); 16  FULLSCREEN = false; 17  try { 18  SCREEN_WIDTH = Gdx.graphics.getWidth(); 19  SCREEN_HEIGHT = Gdx.graphics.getHeight(); 20  } catch (Exception e) { 21  SCREEN_WIDTH = 1920; 22  SCREEN_HEIGHT = 1080; 23  } 24  ASPECT_RATIO = !FULLSCREEN ? 1.0f / 1.0f : (float) SCREEN_WIDTH / (float) SCREEN_HEIGHT; 25  VIEWPORT_HEIGHT = !FULLSCREEN ? 800 : SCREEN_HEIGHT; 26  VIEWPORT_WIDTH = !FULLSCREEN ? (int) (ASPECT_RATIO * VIEWPORT_HEIGHT) : SCREEN_WIDTH; 27  HALF_VIEWPORT_HEIGHT = VIEWPORT_WIDTH / 2; 28  HALF_VIEWPORT_WIDTH = VIEWPORT_HEIGHT / 2; 29  DIMENSIONS = new Vector2(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 30  HALF_DIMENSIONS = new Vector2(HALF_VIEWPORT_WIDTH, HALF_VIEWPORT_HEIGHT); 31  VIEWPORT_TITLE = "Pirate Game"; 32  BACKGROUND_COLOUR = new Vector3(0.0f, 0.0f, 0.0f); 33  PHYSICS_TIME_STEP = 1.0f / 60.0f; 34  35  OPERATING_SYSTEM = System.getProperty("os.name"); 36  37  TILE_SIZE = 32; 38  } 39  40  /** 41  * Update viewport data on resize 42  * 43  * @param x new dim x 44  * @param y new dim y 45  */ 46  public static void UPDATE_VIEWPORT(int x, int y) { 47  VIEWPORT_HEIGHT = y; 48  VIEWPORT_WIDTH = x; 49  ASPECT_RATIO = (float) SCREEN_WIDTH / (float) SCREEN_HEIGHT; 50  HALF_VIEWPORT_HEIGHT = VIEWPORT_HEIGHT / 2; 51  HALF_VIEWPORT_WIDTH = VIEWPORT_WIDTH / 2; 52  DIMENSIONS = new Vector2(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 53  HALF_DIMENSIONS = new Vector2(HALF_VIEWPORT_WIDTH, HALF_VIEWPORT_HEIGHT); 54  } 55  56  public static int SCREEN_WIDTH; 57  public static int SCREEN_HEIGHT; 58  public static boolean FULLSCREEN; 59  public static float ASPECT_RATIO; 60  public static int VIEWPORT_HEIGHT; 61  public static int VIEWPORT_WIDTH; 62  public static int HALF_VIEWPORT_HEIGHT; 63  public static int HALF_VIEWPORT_WIDTH; 64  public static Vector2 DIMENSIONS; 65  public static Vector2 HALF_DIMENSIONS; 66  public static String VIEWPORT_TITLE; 67  public static float PHYSICS_TIME_STEP; 68  public static final float ZOOM = 1.75f; 69  public static final boolean VSYNC = true; 70  public static final float BUILDING_SCALE = 1.5f; 71  72  public static float TILE_SIZE; 73  74  public static Vector3 BACKGROUND_COLOUR; 75  76  public static String OPERATING_SYSTEM; 77 }