Package game

Source Code of game.Game

package game;

import beans.core.GeneralConstant;
import beans.core.db.Database;
import game.core.event.Event;
import game.model.GUIModel;
import game.model.GameModel;
import game.model.TitleModel;
import java.awt.Color;
import java.awt.KeyboardFocusManager;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JFrame;

/**
* Fenetre principale du jeu
*
* @see GameModel
* @see GUIModel
* @author mastersnes
*/
public class Game extends JFrame implements Observer {

    private GUIModel guiModel;

    /**
     *
     */
    public Game() {
        super("GameOfFoo");
        setBackground(Color.BLACK);
        guiModel = new GUIModel();
        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new Event());
        final TitleModel titleModel = new TitleModel(guiModel);
        //final GameModel gameModel = new GameModel(guiModel);
        guiModel.addObserver(this);

        this.setContentPane(guiModel.getScreen());
        this.setResizable(false);
        this.setSize(GeneralConstant.TAILLE_ECRAN_X, GeneralConstant.TAILLE_ECRAN_Y);
        this.setVisible(true);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    /**
     *
     * @param args
     */
    public static void main(final String[] args) {
        Game g = new Game();
    }

    @Override
    public void update(final Observable o, final Object arg) {
        guiModel = (GUIModel) o;
        if (guiModel.isDispose()) {
            Database.close();
            this.dispose();
        } else {
            this.setContentPane(guiModel.getScreen());
            guiModel.getScreen().updateUI();
        }
    }
}
TOP

Related Classes of game.Game

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.