function initializeGame()
{
   // create game control instance
   new ScriptObject(gameInstance)
   {
      class = Hexxgame;
      running = false;
   };
   
   // create player control instance
   new t2dSceneObject(playerOne)
   {
      class = Player;
      resource = 0;
      actions = $pref::Game::ActionsStartingAmount;
      bases = 1;
      fields = 1;
      mainBase = "hexfield_3_5";
   };

   new t2dSceneObject(playerTwo)
   {
      class = Player;
      resource = 0;
      actions = $pref::Game::ActionsStartingAmount;
      bases = 1;
      fields = 1;
      mainBase = "hexfield_13_5";
   };
   
   // create resource control instance
   new t2dSceneObject(resControl)
   {
      class = ResourceController;
      resourceFields = "";
   };
   
   // create AI
   new t2dSceneObject(opponentAI)
   {
      class = AIControl;
      allowAnalysis = true;
   };  
    
   // set player control
   gameInstance.setHumanPlayer(playerOne);
   gameInstance.setAIPlayer(playerTwo);
   
   // load the level
   sceneWindow2D.loadLevel("game/data/levels/map1.t2d");   
   
   // undisplay menu
   Canvas.popDialog(menuWindow);
   
   // displayHud
   displayHud();
   
   // start game
   gameInstance.startGame();
   
   // play sound
   alxPlay(startEndSound);
}

function abortGame()
{
   if(isObject(gameInstance))
      gameInstance.endGame(gameInstance.getAIPlayer());
}

function backToMenu()
{
   menuWindow.loadLevel("game/data/levels/common/menu.t2d");
}