Ejemplo n.º 1
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    mainLayout = new QVBoxLayout();
    window = new QWidget();

    gameView = new GameView();
    gameModel = new GameModel();
    topbar = new Topbar();

    QObject::connect(gameModel, SIGNAL(sig_createMap(std::vector<std::shared_ptr<Tile> >)),
                     gameView, SLOT(createWorldMap(std::vector<std::shared_ptr<Tile> >)));
    QObject::connect(gameModel, SIGNAL(sig_putEnemies(std::vector<std::shared_ptr<Enemy> >)),
                     gameView, SLOT(createEnemies(std::vector<std::shared_ptr<Enemy> >)));
    QObject::connect(gameModel, SIGNAL(sig_putHealPck(std::vector<std::shared_ptr<Tile> >)),
                      gameView, SLOT(createHealPcks(std::vector<std::shared_ptr<Tile> >)));
    QObject::connect(gameModel, SIGNAL(sig_getBoundary(int,int)),
                     gameView, SLOT(setBoundary(int,int)));
    QObject::connect(gameModel, SIGNAL(sig_createProta(int,int)),
                     gameView, SLOT(createProta(int,int)));
    QObject::connect(gameModel, SIGNAL(sig_changeProtaPos(int,int)),
                     gameView, SLOT(changeProtaPos(int,int)));
    QObject::connect(gameModel, SIGNAL(sig_changeProtaHealth(float)),
                     gameView, SLOT(changeProtaHealth(float)));
    QObject::connect(gameModel, SIGNAL(sig_changeProtaEnergy(float)),
                     gameView, SLOT(changeProtaEnergy(float)));
    QObject::connect(gameModel,SIGNAL(sig_fightEnemy(std::shared_ptr<Enemy>)),
                     gameView,SLOT(fightEnemy(std::shared_ptr<Enemy>)));
    QObject::connect(gameModel,SIGNAL(sig_recovery(std::shared_ptr<Tile>)),
                     gameView,SLOT(recovery(std::shared_ptr<Tile>)));
    QObject::connect(gameModel, SIGNAL(sig_findPath(std::vector<std::shared_ptr<PathNode>>)),
                     gameView, SLOT(highlightPath(std::vector<std::shared_ptr<PathNode>>)));

    QObject::connect(gameView, SIGNAL(sig_changeProtaPosbyMouse(int,int)),
                     gameModel, SLOT(goDestinationByMouse(int,int)));
    QObject::connect(gameModel,SIGNAL(sig_stopMoving()),
                     gameView, SLOT(stopMoving()));

    gameModel->initialGame();
    mainLayout->addWidget(gameView);

//------------------------test-------------------
    //gameModel->doAnimation(0,0,24,16);
   // gameView->removeHighlight();



      mainLayout->addWidget(topbar);
      QObject::connect(gameModel,SIGNAL(sig_changeProtaHealth(float)),
                       topbar,SLOT(changeHealthValue(float)));
      QObject::connect(gameModel,SIGNAL(sig_changeProtaEnergy(float)),
                       topbar,SLOT(changeEnergyValue(float)));
      QObject::connect(topbar->getAnimation_slider(),SIGNAL(valueChanged(int)),
                        gameModel,SLOT(setAnimationTime(int)));
    window->setLayout(mainLayout);
    this->setCentralWidget(window);

}
Ejemplo n.º 2
0
void testTurn(){ 
	
	Grid<char> board = makeRandomBoard(StandardCubes); 
	Vector<pointT> moves = makeDeltas();

	DrawBoard(4,4); 
	addLetters(board); 
	
	while (true){ 
		cout << "Enter Word: " << endl;
		string s = GetLine(); 
		if (s == "") break; 
		
		cout << "Word entered: " << s << endl;
		Vector<pointT> path; 
		bool res = checkWord(s, board, moves,path); 
		if (res) cout << "checkWord returned true" << endl;
		if (!res) cout << "checkWord returned false" << endl; 
		highlightPath(path); 
		Pause(0.5); 
		clearHighlights(board); 
		
	}
}