org.saltosion.pixelprophecy.util.Globals.java Source code

Java tutorial

Introduction

Here is the source code for org.saltosion.pixelprophecy.util.Globals.java

Source

/*
 * Copyright (C) 2016 Saltosion
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNUss General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.saltosion.pixelprophecy.util;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Globals {

    private static Logger logger = Logger.getLogger(Globals.class.getName());

    public static final float PHYSICS_UPS = 1 / 60f;
    public static final int PHYSICS_VEL_ITERS = 6;
    public static final int PHYSICS_POS_ITERS = 2;

    public static final float VIEWPORT_HEIGHT = 30f;
    public static float ASPECT_RATIO;

    public static final float SPRITE_SCALE = 1 / 4f;
    public static final Vector2 ONE = new Vector2(1, 1);

    public static final boolean PHYSICS_DEBUG = false;
    public static final boolean GUI_DEBUG = false;
    public static final Color GUI_DEBUG_COLOR = new Color(.9f, .1f, .3f, 1f);
    public static final Color GUI_DEBUG_HOVER_COLOR = new Color(.9f, .3f, .6f, 1f);

    public static int WALLS_LAYER = 5;
    public static int ENTITY_LAYER = 6;
    public static int[] FOREGROUND = { 3, 4 };
    public static int[] BACKGROUND = { 0, 1, 2 };

    public static Color parseColor(String color) {
        String[] parts = color.split(";");
        try {
            float r = Float.parseFloat(parts[0]);
            float g = Float.parseFloat(parts[1]);
            float b = Float.parseFloat(parts[2]);
            float a = Float.parseFloat(parts[3]);
            return new Color(r, g, b, a);
        } catch (NumberFormatException e) {
            logger.log(Level.SEVERE, "property 'light' incorrectly set up!");
            Gdx.app.exit();
        }
        return null;
    }
}