Package controller

Source Code of controller.Main

package controller;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;

import view.ButtonPanel;
import view.GameBoard;
import view.MainMenu;
import view.ScoreBoard;
import view.Window;

import model.Config;
import model.Coordinate;
import model.Snake;

/**
* @author Tomas Walander, David Larsson
*/
public class Main implements Config {

  private Round round;
 
  private Window window;
 
  private ButtonPanel buttonPanel;
  private MainMenu mainMenu;
 
  private ArrayList<Snake> players;
  private ArrayList<String> playerNames;
  private ArrayList<Color> colors;
  private ArrayList<Integer> scores;
 
  private ArrayList<Coordinate> usedCoord;
 
 
  public Main() {
   
    playerNames = new ArrayList<String>();
    playerNames.add("Red");
    playerNames.add("Orange");
    playerNames.add("Magenta");
    playerNames.add("Cyan");
   
    players = new ArrayList<Snake>();
    players.add(new Snake(Color.RED));
    players.add(new Snake(Color.ORANGE));
    players.add(new Snake(Color.MAGENTA));
    players.add(new Snake(Color.CYAN));
   
    colors = new ArrayList<Color>();
    colors.add(Color.RED);
    colors.add(Color.ORANGE);
    colors.add(Color.MAGENTA);
    colors.add(Color.CYAN);
 
    initializeWindow();
 
  }
 
   
  private void initializeWindow() {
    window = new Window();
    window.showFrame();
   
    mainMenu = new MainMenu(playerNames,colors);
    window.setFixedSize(mainMenu,GAME_BOARD_WIDTH,GAME_BOARD_HEIGHT-5);
    window.addToMainPanel(mainMenu);
 
    buttonPanel = new ButtonPanel(this);
    window.setFixedWidth(buttonPanel, CONTROL_PANEL_WIDTH);;
    window.addToControlPanel(buttonPanel);
  }
 
 
  public void startGame() {
    Game game = new Game(players,window);
  }
 
 
  //########## MAIN METHOD ONLY USED FOR START UP ##########//
  /**
   * @param args
   */
  public static void main(String[] args) {
    new Main();
  }

}
TOP

Related Classes of controller.Main

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.