package de.miaurizius.jgame2d.core;

import javax.swing.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Logger;

public class Boot {

    public static final Logger logger = Logger.getLogger("JDGame2D");
    public static JFrame window;
    public static GamePanel gamePanel;

    static {
        try {
            gamePanel = new GamePanel();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        generateWindow();

        gamePanel.setupGame();
        gamePanel.startGameThread();
    }

    public static void generateWindow() {
        window = new JFrame();
        window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        window.setResizable(false);
        window.setTitle("JGame2D");

        window.add(gamePanel);

        gamePanel.config.load();
        if(gamePanel.fullscreen) window.setUndecorated(true);

        window.pack();

        window.setLocationRelativeTo(null);
        window.setVisible(true);
    }

}
