Exemplo n.º 1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    gameScene = new GameScene(this);
    ui->gameView->setScene(gameScene);

    connect(ui->selectButton, SIGNAL(pressed()), this, SLOT(selectGame()));
    connect(ui->loadButton, SIGNAL(pressed()), this, SLOT(loadGame()));
    connect(ui->againButton, SIGNAL(pressed()), this, SLOT(againGame()));
    connect(ui->previousButton, SIGNAL(pressed()), this, SLOT(previousGame()));
    connect(ui->nextButton, SIGNAL(pressed()), this, SLOT(nextGame()));
    connect(ui->computeButton, SIGNAL(pressed()), this, SLOT(computeGame()));
    connect(ui->answerButton, SIGNAL(pressed()), this, SLOT(answerGame()));

    QSignalMapper *signalMapper = new QSignalMapper(this);
    connect(ui->actionEasy, SIGNAL(triggered()), signalMapper, SLOT(map()));
    connect(ui->actionMedium, SIGNAL(triggered()), signalMapper, SLOT(map()));
    connect(ui->actionHard, SIGNAL(triggered()), signalMapper, SLOT(map()));
    signalMapper->setMapping(ui->actionEasy, 0);
    signalMapper->setMapping(ui->actionMedium, 1);
    signalMapper->setMapping(ui->actionHard, 2);
    connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(selectGame(int)));

    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(displayAbout()));

    gameNumber=-1;
}
Exemplo n.º 2
0
MainWindow::MainWindow( GameEngine * currentEngine) :
 isGameLaunched(false),keystate()
{
  currentGameEngine = currentEngine ;

  // menubar creation
  menuBar = new QMenuBar();
  QMenu * gameMenu = menuBar->addMenu("Game");
  gameMenu->addAction("New Game",this,SLOT(diplayNewGame()));
  gameMenu->addAction("Stop Game",currentGameEngine, SLOT(stop()));
  gameMenu->addAction("Options",this, SLOT(displayOptions()));
  gameMenu->addSeparator();
  gameMenu->addAction("Quit",qApp,SLOT(quit()));
  QMenu * helpMenu = menuBar->addMenu("Help");
  helpMenu->addAction("About chmeup",this,SLOT(displayAbout()));

  setFixedSize(screenWidthGlobal + 2 * BORDER_WIDTH ,screenHeightGlobal + menuBar->sizeHint().height() + 2* BORDER_HEIGHT);

  // central widget
  setCentralWidget(&screen);

  connect(currentGameEngine, SIGNAL(updateUI()), this, SLOT(update())) ;
  connect(currentGameEngine, SIGNAL(requestKeyUI()),this,SLOT(keysNeeded()));
  connect(currentGameEngine, SIGNAL(displayGameOverScreen()), this, SLOT(gameOverDisplay()));
  connect(currentGameEngine, SIGNAL(displayGameWonScreen()),this,SLOT(gameWonDisplay()));
  connect(this,SIGNAL(sendKeys(KeyPressedFrame * )),currentGameEngine,SLOT(getKeyFrame(KeyPressedFrame *)));
  connect(this,SIGNAL(sendPause()), currentGameEngine, SLOT(pause()));

  setMenuBar(menuBar);

}
Exemplo n.º 3
0
	//initializes the postion variables for ball
	void initializeVariables(){
		b.cx=b.cx+b.xIncre;
		b.cy=b.cy+b.yIncre;
		b.lefty=b.righty=abs(b.cy);
		b.leftx=abs(b.cx)-b.radius;
		b.rightx=abs(b.cx)+b.radius;
		b.upx=b.downx=abs(b.cx);
		b.upy=abs(b.cy)-b.radius;
		b.downy=abs(b.cy)+b.radius;
		b.downleftx=abs(b.cx)-b.radius*sin(0.785);
		b.downlefty=abs(b.cy)-b.radius*cos(0.785);
		b.downrightx=abs(b.cx)+b.radius*sin(0.785);
		b.downrighty=abs(b.cy)+b.radius*cos(0.785);
		if((b.downrightx==br.left&&b.downrighty==br.up)||(b.downlefty==br.up&&b.downleftx==br.right)){
			b.cx=b.cx*(-1);
			b.cy=b.cy*(-1);
		}
		if(abs(b.leftx)==b.llimit||abs(b.rightx)==b.rlimit)
			b.cx=b.cx*(-1);
		if(((abs(b.downy))==br.up)&&(abs(b.downx)>=br.left&&abs(b.downx)<=br.right))
			b.cy=b.cy*(-1);
		if(abs(b.upy)==b.ulimit)
			b.cy=b.cy*(-1);
		if(abs(b.downy>480)){
			settextstyle(0,0,1);
			b.lives--;
			if(b.lives<0){
				settextstyle(0,0,2);
				outtextxy(230,240,"Game Over. Thank You!!!");
				getch();
				displayAbout();
				exit(0);
			}
			setLivesString();
			outtextxy(200,240,livesRemain);
			changeLives();
			b.cx=20;
			b.cy=240;
			br.removePreviousBar();
			br.rePositionBar(0);
			br.drawBar();
			setcolor(0);
			setfillstyle(1,0);
			getch();
			erase[0]=erase[6]=200;
			erase[1]=erase[3]=240;
			erase[2]=erase[4]=400;
			erase[5]=erase[7]=260;
			fillpoly(4,erase);
			setcolor(15);
			setfillstyle(1,15);
		}

	}
Exemplo n.º 4
0
bool        _HYConsoleWindow::_ProcessMenuSelection (long msel)
{
    switch (msel) {
    case HY_WINDOW_MENU_ID_FILE+1:
        SaveConsole ();
        return true;

    case 14:
        _DoPrint ();
        return true;

    case 16:
        ((_HYTextBox*)GetObject(0))->_DoUndo(true);
        return true;

    case 17:
        ((_HYTextBox*)GetObject(0))->_DoCut(true);
        return true;

    case 18:
        ((_HYTextBox*)GetObject(0))->_DoCopy(true);
        return true;

    case HY_WINDOW_MENU_ID_EDIT+5:
        ((_HYTextBox*)GetObject(0))->_DoSelectAll(true);
        return true;

    case 21:
        SetStatusLine ("Canceling");
        terminateExecution = true;
        return true;

    case 22: {
        GtkWidget * suspendItem = gtk_item_factory_get_widget_by_action(menu_items,22);
        if (!isSuspended) {
            isSuspended = true;
            SetStatusLine (empty,empty,empty,-1,HY_SL_SUSPEND);
            gtk_label_set_text (GTK_LABEL (gtk_bin_get_child(GTK_BIN(suspendItem))), "Resume");
            updateTimer = false;
            while (isSuspended) {
                gtk_main_iteration_do(true);
            }
        } else {
            isSuspended = false;
            SetStatusLine (empty,empty,empty,-1,HY_SL_RESUME);
            gtk_label_set_text (GTK_LABEL (gtk_bin_get_child(GTK_BIN(suspendItem))), "Suspend execution");
            timerStart += clock()-lastTimer;
            updateTimer = true;
        }
        return true;
    }
    case 23:
        ShowMessagesLog();
        return true;

    case 24:
        RunStandardAnalyses();
        return true;

    case 25:
        displayAbout(false);
        return true;

    case HY_WINDOW_MENU_ID_EDIT+4:
        ((_HYTextBox*)GetObject(0))->_DoClear (true,true);
        return true;

    case 27:
        HandlePreferences (globalPreferencesList,"HYPHY Preferences");
        return true;

    case 29:
        //WinExec ("hh HYPHY HELP.chm",SW_SHOWNORMAL);
        return true;

    case 30:
        if (OpenBatchFile (false)) {
            ExecuteBatchFile();
            PopFilePath();
        }
        return true;

    case 31:
        ((_HYTextBox*)GetObject(0))->_DoRedo(true);
        return true;

    case 15:
        postWindowCloseEvent (GetID());
        gtk_main_quit ();
        return true;

    case 60: // expression calculator
        if (calculatorMode) {
            _HYTextBox         *ib = (_HYTextBox*)hyphyConsoleWindow->GetObject(1);
            ib->SetText ("exit");
            hyphyConsoleWindow->ProcessEvent (generateTextEditChangeEvent(ib->GetID(),2));
            calculatorMode         = false;
            //ib->SetText (empty);
        } else {
            calculatorMode = true;
            while(calculatorMode&&ExpressionCalculator()) {}
            calculatorMode = false;
        }
        return true;

    case 61: { // execute selection
        ExecuteSelection();
        return true;
    }

    case 70: // New Tree
        NewTreeWindow(-1);
        return true;

    case 71: // New Model
        NewModel(nil);
        return true;

    case 72: // New Chart
        NewChartWindow();
        return true;

    case 73: // New Genetic Code
        NewGeneticCodeTable(0);
        return true;

    case 74: // New Database
        NewDatabaseFile(0);
        return true;

    case 80: // Open Batch File
        if (OpenBatchFile()) {
            ExecuteBatchFile ();
        }
        return true;

    case 81: // Open Data File
        OpenDataFile();
        return true;

    case 82: // Open Tree
        OpenTreeFile();
        return true;

    case 83: // Open Text
        OpenTextFile();
        return true;

    case 84: // Open Table
        OpenTable ();
        return true;

    case 85: // Open SQLite database
        OpenDatabaseFile (nil);
        return true;

    case HY_WINDOW_MENU_ID_FILE-2:
        ShowObjectInspector ();
        return true;

    default: {
        msel -= 1000;
        if (msel<availablePostProcessors.lLength) {
            ExecuteAPostProcessor (*(_String*)(*(_List*)availablePostProcessors(msel))(1));
            return 0;
        }

        msel-=1000;
        if (msel<(long)recentPaths.lLength) {
            if (msel == -1) {
                for (long mi=0; mi<recentFiles.lLength; mi++) {
                    GtkWidget * recFile = gtk_item_factory_get_widget_by_action(hyphyConsoleWindow->menu_items,2000+mi);
                    if (recFile) {
                        gtk_item_factory_delete_item(hyphyConsoleWindow->menu_items,gtk_item_factory_path_from_widget(recFile));
                    }
                }
                recentPaths.Clear();
                recentFiles.Clear();
            } else {
                if (argFileName) {
                    *argFileName = *(_String*)recentPaths(msel);
                } else {
                    argFileName = new _String (*(_String*)recentPaths(msel));
                }
                if (OpenBatchFile(false)) {
                    ExecuteBatchFile ();
                }
            }
            return true;
        }
        return true;
    }
    }

    return _HYTWindow::_ProcessMenuSelection(msel);
}
Exemplo n.º 5
0
	//function which centrally controls the execution of game
	void gameHandler(){
		settextstyle(0,0,6);
		outtextxy(180,200,"DX-Ball");
		getch();
		clearviewport();
		brickLen=25,brickBred=15;
		for(int i=0;i<20;i++)
			for(int j=0;j<8;j++)
				isBrick[i][j]=1;
		drawBricks();
		b.cx=20;
		b.cy=240;
		b.xIncre=1;
		b.yIncre=1;
		b.radius=5;
		br.size=80;
		br.movement=10;
		score=0;
		livesRemain[0]=' ';
		livesRemain[1]=' ';
		strcat(livesRemain,"live(s) remaining.");
		b.lives=3;
		line(500,0,500,480);
		settextstyle(0,0,2);
		outtextxy(535,200,"Score:");
		settextstyle(0,0,2);
		setScoreString();
		outtextxy(535,230,scoreString);
		outtextxy(535,320,"Lives:");
		setLivesString();
		outtextxy(565,350,livesString);
		b.ulimit=0;
		b.llimit=0;
		b.rlimit=500;
		br.llimit=0;
		br.rlimit=500;
		br.rePositionBar(0);
		br.drawBar();
		int ch='a';
		while(1){
			while(!kbhit()){
			delay(4);
			b.removePreviousBall();
			changeScore();
			initializeVariables();
			whetherBallTouchesBrick();
			b.drawBall();
			br.removePreviousBar();
			br.drawBar();
			line(500,0,500,480);
			}
			ch=getch();
			if(ch=='a'){
				br.removePreviousBar();
				br.rePositionBar('a');
				br.drawBar();
			}
			if(ch=='s'){
				br.removePreviousBar();
				br.rePositionBar('s');
				br.drawBar();
			}
			if(ch=='p')
				ch=getch();
			if(ch=='q'){
				displayAbout();
				getch();
				exit(0);
			}
		}
	}