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();
}
}
}