/**
 * This function displays the window after winning the first task.
 * @brief RoundOne::displayWinnerWindow creates a panel to obscure the background and places a message on the screen along with a round2 button.
 * @param text is the message displayed in the window.
 */
void RoundOne::displayWinnerWindow(QString text)
{

    ///obscure game window with panel
    drawPanel(0,0,800,600, Qt::darkYellow, 0.6);
    ///make another panel with message
    drawPanel(200, 100, 400, 300, Qt::darkMagenta, 0.75);

    ///display message
    QGraphicsTextItem* message= new QGraphicsTextItem(text);
    message->setFont(QFont("lucida blackletter", 20));
    message->setPos(210, 130);

    scene_one->addItem(message);

    QGraphicsPixmapItem* golden= new QGraphicsPixmapItem;
    golden->setPixmap(QPixmap(":/new/prefix1/goldegg.png"));
    golden->setScale(0.1);
    golden->setPos(370, 220);
    scene_one->addItem(golden);

    ///create a button and add it to the scene
    QPushButton* round2= new QPushButton("Start Round 2");
    round2->setFont(QFont("lucida blackletter", 20));
    round2->setGeometry(310, 310, 170, 90);
    scene_one->addWidget(round2);

    ///connect the round2 button with the slot display_menu_two()
    connect(round2, SIGNAL(clicked(bool)), this, SLOT(display_menu_two()));
}
/**
 * This function displays the window after winning the second task.
 * @brief RoundOne::displayWinnerWindowRoundTwo creates a panel to obscure the background and places a message on the screen along with a round3 button.
 * @param text is the message displayed in the window.
 */
void RoundOne::displayWinnerWindowRoundTwo(QString text)
{
    //get rid of all scene items
    scene_one->clearFocus();
    //get ride of seaweed in front of Ron
    delete p9;
    //obscure game window with panel
    drawPanel(0,0,800,600, Qt::darkYellow, 0.4);
    //make another panel with message
    drawPanel(200, 100, 400, 300, Qt::darkMagenta, 0.6);

    //display message
    QGraphicsTextItem* message= new QGraphicsTextItem(text);
    message->setFont(QFont("lucida blackletter", 20));
    message->setPos(210, 140);
    scene_one->addItem(message);

    QGraphicsPixmapItem* found_friend= new QGraphicsPixmapItem;
    found_friend->setPixmap(QPixmap(":/new/prefix1/l_ron-young-standing.png"));
    found_friend->setPos(480, 220);
    scene_one->addItem(found_friend);

    ///create a button and add it to the scene
    QPushButton* round3= new QPushButton("Start Round 3");
    round3->setFont(QFont("lucida blackletter", 20));
    round3->setGeometry(310, 280, 170, 90);
    scene_one->addWidget(round3);

    ///connect the round3 button with the slot display_menu_three()
    connect(round3, SIGNAL(clicked(bool)), this, SLOT(display_menu_three()));
}
Beispiel #3
0
void Game::showGameOverMenu(int player_id) {
    int n = scene->items().size();
    for(int i = 0; i < n; i++) {
        scene->items()[i]->setEnabled(false);
    }
    drawPanel(0, 0, 1024, 768, QColor(Qt::lightGray), 0.65);
    drawPanel(1024/2 - 200,200,400,400,QColor(Qt::darkGray), 0.85);
    QGraphicsTextItem *lbl_go_text = new LabelItem("Konec hry", 0, 0);
    lbl_go_text->setPos(scene->width()/2 - lbl_go_text->boundingRect().width()/2, 250);
    scene->addItem(lbl_go_text);
    QGraphicsTextItem *lbl_player_won = new LabelItem(QString("Vyhral hrac c. %1").arg(player_id), 0, 0);
    lbl_player_won->setPos(scene->width()/2 - lbl_player_won->boundingRect().width()/2, 275);
    scene->addItem(lbl_player_won);
    Button *restart_btn = new Button(QString("Hrat znovu"));
    int x = scene->width()/2 - restart_btn->boundingRect().width()/2;
    int y = 325;
    restart_btn->setPos(x, y);
    connect(restart_btn, SIGNAL(clicked()), this, SLOT(startGame()));
    scene->addItem(restart_btn);

    Button *back_to_menu_btn = new Button(QString("Vratit do menu"));
    x = scene->width()/2 - back_to_menu_btn->boundingRect().width()/2;
    y += 75;
    back_to_menu_btn->setPos(x, y);
    connect(back_to_menu_btn, SIGNAL(clicked()), this, SLOT(showMainMenu()));
    scene->addItem(back_to_menu_btn);

    Button *exit_btn = new Button(QString("Konec"));
    x = scene->width()/2 - exit_btn->boundingRect().width()/2;
    y += 75;
    exit_btn->setPos(x, y);
    connect(exit_btn, SIGNAL(clicked()), this, SLOT(close()));
    scene->addItem(exit_btn);
}
Beispiel #4
0
void PictureDecorator::draw( Picture& dstpic, const Rect& rectangle, Mode mode, bool useAlpha )
{
  switch( mode )
  {
  case whiteArea: drawArea( dstpic, rectangle, 348, 10, 12, useAlpha ); break;  
  case blackArea: drawArea( dstpic, rectangle, 487, 5, 7, useAlpha ); break;
  case greyPanel: drawPanel( dstpic, rectangle, 25, useAlpha ); break;
  case lightgreyPanel: drawPanel( dstpic, rectangle, 22, useAlpha ); break;
  case smallBrownPanel: drawPanel( dstpic, rectangle, 65, useAlpha ); break;
  case smallGreyPanel: drawPanel( dstpic, rectangle, 68, useAlpha ); break;
  case whiteBorder: drawBorder( dstpic, rectangle, 336, 468, 347, 358, 10, 12, 335, 467, 346, 478, useAlpha );  break;
  case blackBorder: drawBorder( dstpic, rectangle, 480, 522, 486, 492, 5, 7, 479, 521, 485, 527, useAlpha ); break;
  case brownBorder: drawBorder(dstpic, rectangle, 555, useAlpha ); break;
  case whiteBorderA: drawBorder( dstpic, rectangle, 547, useAlpha ); break;
  case whiteFrame:
    draw( dstpic, Rect( rectangle.UpperLeftCorner + Point( 16, 16 ), rectangle.LowerRightCorner - Point( 16, 16 ) ), whiteArea );    // draws the inside of the box
    draw( dstpic, rectangle, whiteBorder );    // draws borders
  break;

  case blackFrame:
    draw(dstpic, Rect( rectangle.UpperLeftCorner + Point( 16, 16 ), rectangle.LowerRightCorner - Point( 16, 16 ) ), blackArea );    // draws the inside of the box
    draw(dstpic, rectangle, blackBorder );    // draws borders
  break;

  case brownFrame: drawFrame(dstpic, rectangle, 28, useAlpha); break;
  case greyFrame: drawFrame(dstpic, rectangle, 37, useAlpha); break;
  }
}
/*
 * drawScene() handles the animation and the redrawing of the
 *		graphics window contents.
 */
void drawScene(void)
{
    int i, k, x, y;
    float *color;

	// Clear the rendering window
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    /* Draw Board */
    drawBoard( );

    /* Draw Panel */
    drawPanel( );

    /* Draw the stones of all turns */
    glBegin(GL_POINTS);
    for ( i = 0; i < g_curr_turn + 1; i++ ) {
        /* For all players */
        for ( k = 0; k < g_num_players; k++ ) {
            /* Draw if the player has already played this turn */
            if ( i < g_curr_turn || (k < g_curr_player && i == g_curr_turn) ) {
                x = g_players[k].stones[i].x;
                y = g_players[k].stones[i].y;
                color = g_players[k].color;
                glColor3f( color[0], color[1], color[2] );
                glVertex2f( x, y );
            }
        }
    }
    glEnd();

	// Flush the pipeline.  (Not usually necessary.)
	glFlush();

}
Beispiel #6
0
/**This function displays the window after losing the game.
 * @brief Game::lose() creates a panel to obscure the background and places a message on the screen along with quit and retry buttons.
 */
void Game::lose(){
    // play lose music
    lose_music->play();

    // stop game music
    game_music->stop();

    ash_lose = true;
    clearFocus();
    drawPanel(400,0,400,400,QBrush(QImage(":/new/prefix1/sad_pika.png").scaledToWidth(400)), 1);
    QGraphicsTextItem* message= new QGraphicsTextItem("GAME OVER");
    message->setDefaultTextColor(Qt::red);
    message->setFont(QFont("Gill Sans",40));
    message->setPos(500, 75);
    scene->addItem(message);

    QPushButton* quit_button= new QPushButton("Quit");
    quit_button->setGeometry(450, 200, 80, 40);
    scene->addWidget(quit_button);

    QPushButton* retry_button = new QPushButton("Retry");
    retry_button->setGeometry(650,200,80,40);
    scene->addWidget(retry_button);

    QObject::connect(quit_button, SIGNAL(clicked(bool)), this, SLOT(close()));
    QObject::connect(retry_button,SIGNAL(clicked(bool)),this,SLOT(retry()));
}
Beispiel #7
0
/**This function displays the window after winning the game.
 * @brief Game::win() creates a panel to obscure the background and places a message on the screen along with quit and retry buttons.
 */
void Game::win(){
    // play win music
    win_music->play();

    // stop game music
    game_music->stop();

    ash_win = true;

    clearFocus();
    drawPanel(400,0,400,400,QBrush(QImage(":/new/prefix1/Ca1P-6TVAAE6x19.jpg").scaledToWidth(400)), 1);
    QGraphicsTextItem* message= new QGraphicsTextItem("YOU WON!!");
    message->setFont(QFont("Gill Sans",40));
    message->setPos(500, 100);
    scene->addItem(message);

    QPushButton* quit_button= new QPushButton("Quit");
    quit_button->setGeometry(450, 200, 80, 40);
    scene->addWidget(quit_button);

    QPushButton* retry_button = new QPushButton("Retry");
    retry_button->setGeometry(650,200,80,40);
    scene->addWidget(retry_button);

    QObject::connect(quit_button, SIGNAL(clicked(bool)), this, SLOT(close()));
    QObject::connect(retry_button,SIGNAL(clicked(bool)),this,SLOT(retry()));
}
Beispiel #8
0
void CommandPanel::paintEvent(QPaintEvent *event)
{
   QPixmap pix(size());
   QPainter buffer(&pix);
   //
   buffer.setClipRect(event->rect());
   drawPanel(buffer, event->rect());
   //
   QPainter painter(this);
   painter.drawPixmap(QPoint(0, 0), pix);
}
Beispiel #9
0
void drawScreenInt() {
  // Очистка экрана
  fillRect(radio86rkVideoMem, 64, ROWS_CNT+8, ' ');

  // Рисуем подсказку    
  print(1, ROWS_CNT+7, "F1 FREE F2 NEW  F3 VIEW  F4 EDIT F5 COPY F6 REN  F7 DIR  F8 DEL"); 

  // Рисуем панели
  drawPanel(radio86rkVideoMem + 1);
  drawPanel(radio86rkVideoMem + 33);

  // Рисуем заголовки панелей
  drawPanelTitle(1);
  swapPanels();
  drawPanelTitle(0);
  swapPanels();

  // Курсора нет
  fileCursorAddr = 0;
}
Beispiel #10
0
void Journal::drawYesNoPanel(int titleNum) {
    static const int frames[] = { FRAME_GREY, FRAME_BLUE_1, FRAME_BLUE_2 };
    const int titles[] = { titleNum, TXT_YES, TXT_NO };
    drawPanel(frames, titles, 3);

    hideBob(BOB_LEFT_RECT_4);
    hideBob(BOB_TALK_SPEED);
    hideBob(BOB_SFX_TOGGLE);
    hideBob(BOB_MUSIC_VOLUME);
    hideBob(BOB_SPEECH_TOGGLE);
    hideBob(BOB_TEXT_TOGGLE);
    hideBob(BOB_MUSIC_TOGGLE);
}
/**
 * This function displays the window after losing the first task.
 * @brief RoundOne::displayGameOverWindow creates a panel to obscure the background and places a message on the screen along with a retry button.
 * @param text is the message displayed in the window.
 */
void RoundOne::displayGameOverWindow(QString text){

    ///obscure game window with panel
    drawPanel(0,0,800,600, Qt::green, 0.6);
    ///make another panel with message
    drawPanel(200, 100, 400, 300, Qt::lightGray, 0.75);

    ///display message
    QGraphicsTextItem* message= new QGraphicsTextItem(text);
    message->setFont(QFont("lucida blackletter", 20));
    message->setPos(210, 225);

    scene_one->addItem(message);

    ///create a retry button and add it to the scene
    QPushButton* retry= new QPushButton("Replay");
    retry->setFont(QFont("lucida blackletter", 20));
    retry->setGeometry(270, 270, 100, 70);
    scene_one->addWidget(retry);

    ///create a retry button and add it to the scene
    QPushButton* give_up= new QPushButton("Give Up");
    give_up->setFont(QFont("lucida blackletter", 20));
    give_up->setGeometry(400, 270, 100, 70);
    scene_one->addWidget(give_up);

    QGraphicsPixmapItem* big_dragon= new QGraphicsPixmapItem;
    big_dragon->setPixmap(QPixmap(":/new/prefix1/horntail.png"));
    big_dragon->setPos(220, 0);
    big_dragon->setScale(0.28);
    scene_one->addItem(big_dragon);

    ///connect the retry button with the slot retry_round_one()
    connect(retry, SIGNAL(clicked(bool)), this, SLOT(retry_round_one()));
    ///connect the give_up button to close()
    connect(give_up, SIGNAL(clicked(bool)), this, SLOT(close()));
}
Beispiel #12
0
void Game::showInGameMenu(){
    menu = true;
    int n = scene->items().size();
    for(int i = 0; i < n; i++) {
        scene->items()[i]->setEnabled(false);
    }
    drawPanel(0, 0, 1024, 768, QColor(Qt::lightGray), 0.65);
    drawPanel(1024/2 - 200,200,400,400,QColor(Qt::darkGray), 0.85);

    Button *resume_btn = new Button(QString("Vratit do hry"));
    int x = scene->width()/2 - resume_btn->boundingRect().width()/2;
    int y = 250;
    resume_btn->setPos(x, y);
    connect(resume_btn, SIGNAL(clicked()), this, SLOT(updateGame()));
    scene->addItem(resume_btn);

    Button *save_game_btn = new Button(QString("Ulozit hru"));
    x = scene->width()/2 - save_game_btn->boundingRect().width()/2;
    y += 75;
    save_game_btn->setPos(x, y);
    //connect(save_game_btn, SIGNAL(clicked()), this, SLOT(showMainMenu()));
    scene->addItem(save_game_btn);

    Button *back_to_menu_btn = new Button(QString("Vratit do menu"));
    x = scene->width()/2 - back_to_menu_btn->boundingRect().width()/2;
    y += 75;
    back_to_menu_btn->setPos(x, y);
    connect(back_to_menu_btn, SIGNAL(clicked()), this, SLOT(showMainMenu()));
    scene->addItem(back_to_menu_btn);

    Button *exit_btn = new Button(QString("Konec"));
    x = scene->width()/2 - exit_btn->boundingRect().width()/2;
    y += 75;
    exit_btn->setPos(x, y);
    connect(exit_btn, SIGNAL(clicked()), this, SLOT(close()));
    scene->addItem(exit_btn);
}
/**
 * This function displays the window after losing the second task.
 * @brief RoundOne::displayGameOverWindowRoundTwo creates a panel to obscure the background and places a message on the screen along with a retry button.
 * @param text is the message displayed in the window.
 */
void RoundOne::displayGameOverWindowRoundTwo(QString text)
{
    drawPanel(0,0,800,600, Qt::green, 0.4);
    ///make another panel with message
    drawPanel(200, 100, 400, 300, Qt::lightGray, 0.55);

    ///display message
    QGraphicsTextItem* message= new QGraphicsTextItem(text);
    message->setFont(QFont("lucida blackletter", 20));
    message->setPos(210, 100);

    scene_one->addItem(message);


    QGraphicsPixmapItem* mermaid= new QGraphicsPixmapItem;
    mermaid->setPixmap(QPixmap(":/new/prefix1/mermaid.jpg"));
    mermaid->setPos(250, 185);
    scene_one->addItem(mermaid);

    ///create a retry button and add it to the scene
    QPushButton* retry= new QPushButton("Replay");
    retry->setFont(QFont("lucida blackletter", 14));
    retry->setGeometry(310, 360, 80, 40);
    scene_one->addWidget(retry);

    ///create a retry button and add it to the scene
    QPushButton* give_up= new QPushButton("Give Up");
    give_up->setFont(QFont("lucida blackletter", 14));
    give_up->setGeometry(410, 360, 80, 40);
    scene_one->addWidget(give_up);

    ///connect the retry button with the slot retry_round_two()
    connect(retry, SIGNAL(clicked(bool)), this, SLOT(retry_round_two()));
    ///connect the give_up button with the slot close()
    connect(give_up, SIGNAL(clicked(bool)), this, SLOT(close()));
}
Beispiel #14
0
/* function that draws window with all stuff */
void draw(void)
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();
  /* draw working window and panel with set of tools */
  drawGrid();
  drawPanel(mapState.border);
  glColor3f(0, 0, 0);
  drawBitmapText("Tools", BITMAPTEXT_X, BITMAPTEXT_Y);
  drawButtons();
  passiveLineMotion(mapState.points_storage, mapState.previous_point, mapState.passive_motion_point);
  drawEdgeVertices(mapState.points_storage, RADIUS_OF_POINT);
  drawEdges(mapState.edges_storage);
  checkSelectedPoint(mapState.points_storage, mapState.passive_motion_point);
  markSelectedPoint(mapState.previous_point, mapState.selected_point, SIZE_OF_SHINING_CIRCLE);
  glutSwapBuffers();
  glFlush();
}
Beispiel #15
0
static char *
askString( char * str )
{
	char c;
	static char error[MAX_ERR_LEN];
	static char buffer[MAX_COM_LEN];

	do{
		clearScreen();
		drawText( NULL );
		drawPanel( error );
		askCommand( buffer );
		raiseErrorIf( errorCode() == NOERROR, errorCode(), NULL );
		error[0] = 0;
		if( ( c = sscanf( buffer, " %s", str ) ) != 1 && buffer[0] != '\n' )
			sprintf( error, "Format error:\nMust be a string" );
	}while( c != 1 );
	return str;
}
Beispiel #16
0
void Decorator::draw( Pictures& stack, const Rect& rectangle, Decorator::Mode mode, Rects* rects, bool negY )
{
  switch( mode )
  {
  case whiteArea: drawArea( stack, rectangle, 348, 10, 12 ); break;
  case blackArea: drawArea( stack, rectangle, 487, 5, 7 ); break;
  case greyPanel: drawPanel( stack, rectangle, 25, rects ); break;
  case lightgreyPanel: drawPanel( stack, rectangle, 22, rects ); break;
  case greyPanelBig: drawPanel( stack, rectangle, 631, rects ); break;
  case lightgreyPanelBig: drawPanel( stack, rectangle, 634, rects ); break;
  case greyPanelSmall: drawPanel( stack, rectangle, 68, rects ); break;
  case brownPanelSmall: drawPanel( stack, rectangle, 65, rects ); break;
  case greenPanelSmall: drawPanel( stack, rectangle, 62, rects ); break;
  case redPanelSmall: drawPanel( stack, rectangle, 1165, rects ); break;
  case whiteBorder: drawBorder( stack, rectangle, 336, 468, 347, 358, 10, 12, 335, 467, 346, 478 );  break;
  case blackBorder: drawBorder( stack, rectangle, 480, 522, 486, 492, 5, 7, 479, 521, 485, 527 ); break;
  case brownBorder: drawBorder(stack, rectangle, 555 ); break;
  case whiteBorderA: drawBorder( stack, rectangle, 547 ); break;
  case whiteFrame:
  {
    Point offset( 16, 16 );
    draw( stack, Rect( rectangle.lefttop() + offset, rectangle.rightbottom() - offset ), whiteArea );
    draw( stack, rectangle, whiteBorder );    // draws borders
  }
  break;

  case blackFrame:
    draw(stack, Rect( rectangle.lefttop(), rectangle.rightbottom() - Point( 16, 16 ) ), blackArea );    // draws the inside of the box
    draw(stack, rectangle, blackBorder );    // draws borders
  break;

  case brownFrame: drawFrame(stack, rectangle, 28); break;
  case greyFrame: drawFrame(stack, rectangle, 37); break;
  case pure: break;
  default: break;
  }

  if( !negY )
    reverseYoffset( stack );
}
Beispiel #17
0
/**
 * Dessine le plateau de jeu.
 * @param map Le fichier correspondant à la map
 * @param game L'état du jeu
 * @param board Le plateau à afficher
 */
void drawBoard(FILE* map, const GameState* game, char board[ROWS][COLS]) {
    unsigned short x, y;

    for (x = 0; x < ROWS; x++) {
        for (y = 0; y <= COLS; y++) {
            board[x][y] = fgetc(map);

            setColor(getCaseColor(board[x][y]));
            putchar(convertCase(board[x][y]));
        }
    }

    resetColor();

    drawToolbar(game);
    drawPanel();

    printf("\n");

    closeMap(map);
}
Beispiel #18
0
//----------------------------------------------------------------
bool MainScreen::draw() {
	lastTime = currTime;
	currTime = ofGetElapsedTimef();
	dTime = 60 * (currTime - lastTime);
	shader.begin();
	shader.setUniform1i("maxiter", maxiter);
	shader.setUniform1i("supersample", supersample);
	shader.setUniform2f("resolution", resolution);
	shader.setUniform1f("scale", scale);
	shader.setUniform2f("offset", offset);
	shader.setUniform3f("colorgain", colorgain);
	shader.setUniform4f("coloroffset", coloroffset);
	ofRect(0, 0, ofGetWidth() - 300, ofGetHeight());
	shader.end();
	drawPanel();
	if (screenChanged) {
		screenChanged = false;
		return true;
	}
	return false;
}
Beispiel #19
0
static void
ask2Int( int a1, int * n1, int b1, int a2, int * n2, int b2 )
{
	char c;
	static char error[MAX_ERR_LEN];
	static char buffer[MAX_COM_LEN];

	error[0] = 0;
	do{
		clearScreen();
		drawText( NULL );
		drawPanel( error );
		askCommand( buffer );
		raiseErrorIf( errorCode() == NOERROR, errorCode(), );
		error[0] = 0;
		if( ( c = sscanf( buffer, " %d %d %c", n1, n2, &c ) ) != 2 && buffer[0] != '\n' )
			sprintf( error, "Format error:\nMust be two integers, "
						"space separated" );
	}while( c != 2 || !validateInt( a1, *n1, b1+1, error ) ||
						!validateInt( a2, *n2, b2+1, error ) );
}
  void AttitudeIndicatorPlugin::Draw(double x, double y, double scale)
  {
    glPushAttrib(GL_ALL_ATTRIB_BITS);
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0, canvas_->width(), canvas_->height(), 0, -1.0f, 1.0f);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
    // Setup coordinate system so that we have a [-1,1]x[1,1] cube on
    // the screen.
    QRect rect = placer_.rect();
    double s_x = rect.width() / 2.0;
    double s_y = -rect.height() / 2.0;
    double t_x = rect.right() - s_x;
    double t_y = rect.top() - s_y;

    double m[16] = {
        s_x, 0, 0, 0,
        0, s_y, 0, 0,
        0, 0, 1.0, 0,
        t_x, t_y, 0, 1.0};
    glMultMatrixd(m);

    // Placed in a separate function so that we don't forget to pop the
    // GL state back.

    drawBackground();
    drawBall();

    drawPanel();

    glPopMatrix();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopAttrib();
    PrintInfo("OK!");
  }
Beispiel #21
0
static int
askInt( int a, int b )
{
	int sol;
	char c;
	static char error[MAX_ERR_LEN];
	static char buffer[MAX_COM_LEN];

	error[0] = 0;
	do{
		clearScreen();
		drawText( NULL );
		drawPanel( error );
		askCommand( buffer );
		raiseErrorIf( errorCode() == NOERROR, errorCode(), -1 );
		error[0] = 0;
		if ( ( c = sscanf( buffer, " %d %c ", &sol, &c ) ) != 1 && buffer[0] != '\n' )
			sprintf( error, "Format error:\nMust be an integer" );
	}while( c != 1 || !validateInt( a, sol, b+1, error ) );

	return sol;
}
/**
 * This function displays message saying there will be no third task
 * @brief RoundOne::displayMainMenu clears the scene, shows a welcome message, shows the instructions, and has QRadioButtons that let the player choose the level of difficulty and a start game QPushButton that starts the game.
 */
void RoundOne::displayMainMenuThree(){

    ///obscure game window with panel
    drawPanel(0,0,800,600, Qt::darkMagenta, 0.6);


    ///display a message
    QGraphicsTextItem* congrats= new QGraphicsTextItem("You are a true Triwizard Champion!!!");
    congrats->setFont(QFont("lucida blackletter", 45));
    congrats->setPos(30,10);


    QGraphicsTextItem* message= new QGraphicsTextItem("As you may know, Cedric Diggory died \nlast year during this task. \n\nSo this task has a 25% mortality rate, \nwhich is really not good when all of the \nparticipants are children. \nSo, this year we have decided to cancel the \nthird task for your safety. \nCongratulations on finishing the Triwizard \nTournament (or at least the safer parts of it)!");
    message->setFont(QFont("lucida blackletter", 20));
    message->setPos(210, 130);

    scene_one->addItem(congrats);
    scene_one->addItem(message);

    QGraphicsPixmapItem* cup= new QGraphicsPixmapItem;
    cup->setPixmap(QPixmap(":/new/prefix1/cup.png"));
    cup->setScale(0.1);
    cup->setPos(370, 500);
    scene_one->addItem(cup);

    ///create a button and add it to the scene
    QPushButton* end= new QPushButton("Finish Game");
    end->setFont(QFont("lucida blackletter", 20));
    end->setGeometry(310, 400, 170, 90);
    scene_one->addWidget(end);

    QMediaPlayer* winning_music= new QMediaPlayer();
    winning_music->setMedia(QUrl("qrc:/new/prefix2/01 Fireworks.mp3"));
    winning_music->play();

    ///connect the end button with the slot close() to close the game
    connect(end, SIGNAL(clicked(bool)), this, SLOT(close()));
}
Beispiel #23
0
void Journal::drawNormalPanel() {
    static const int frames[] = { FRAME_BLUE_1, FRAME_BLUE_2, FRAME_BLUE_1, FRAME_ORANGE };
    static const int titles[] = { TXT_REVIEW_ENTRY, TXT_MAKE_ENTRY, TXT_CLOSE, TXT_GIVE_UP };
    drawPanel(frames, titles, 4);
}
Beispiel #24
0
bool ShootingCans::draw(bool hit, Vector &hitPoint) {

    switch (mode) {
    case INIT:
        startGame();
        infobox->set("bounce at the cans.");
        break;
    case PLAY:
        // check hit
        if (hit) {
            infobox->clear();
            ballHits++;

            if (!gameStarted) {
                gameStarted = true;
                startTime = ofGetElapsedTimef() + 120;
            }

            for (int i = 0; i < cans.size(); i++) {
                if (cans[i].checkHit(hitPoint)) {
                    points += 100;
                    signs.push_back(Sign("+100", hitPoint, 2.0));

                    shootedCans.push_back(cans[i]);
                    cans.erase(cans.begin() + i);
                    i--;

                    if (points == 1000) {
                        int timeBonus = (startTime - ofGetElapsedTimef()) * 10;
                        points += timeBonus;

                        string bonus = "timebonus: +" + ofToString(timeBonus);
                        signs.push_back(Sign(bonus, Vector((ofGetWidth() - gameFont.stringWidth(bonus)) / 2, ofGetHeight() / 2), 3.0));

                        points -= ballHits * 10;
                        string minus = "ballthrows: -" + ofToString(ballHits * 10);
                        signs.push_back(Sign(minus, Vector((ofGetWidth() - gameFont.stringWidth(minus)) / 2, ofGetHeight() / 2 + 40), 4.0));
                    }
                }
            }
        }

        if (gameStarted)
            screenTime = startTime - ofGetElapsedTimef();

        if ((cans.size() == 0 && signs.size() == 0) || screenTime <= 0)
            stopGame();

        for (int i = 0; i < shootedCans.size(); i++) {
            if (!shootedCans[i].draw()) {
                shootedCans.erase(shootedCans.begin() + i);
                i--;
            }
        }
        drawBg();
        break;
    case PANEL:
        drawBg();
        drawPanel();

        if (hit && !insertName)
            return false;

        break;
    default:
        break;
    }

    drawSigns();

    return true;
}
Beispiel #25
0
void Game::updateGame(){
    scene->clear();
    menu = false;
    int druh;
    int otoceni;
    int cPredmetu;

    for(int i = 0; i < velikost; i++){
        for(int j = 0; j < velikost; j++){
            druh = plan.vrat_druh(i,j);
            otoceni = plan.vrat_otoceni(i,j);
            cPredmetu = plan.vrat_predmet(i,j);

            chodba = new Chodba();
            chodba->vykresliChodbu(druh,otoceni);
            chodba->setPos(60+j*52,60+i*52);
            scene->addItem(chodba);
            if(cPredmetu >= 0){
                predmet = new Predmet();
                predmet->vykresliPredmet(cPredmetu);
                predmet->setPos(75+j*52,75+i*52);
                scene->addItem(predmet);
            }
        }
    }
    createLabels();
    druh = plan.vrat_druh(-1,-1);
    otoceni = plan.vrat_otoceni(-1,-1);
    cPredmetu = plan.vrat_predmet(-1,-1);

    volna_chodba = new Chodba();
    volna_chodba->vykresliChodbu(druh,otoceni);
    volna_chodba->setPos(110+(velikost*52),100);
    scene->addItem(volna_chodba);

    if(cPredmetu >= 0){
        predmet = new Predmet();
        predmet->vykresliPredmet(cPredmetu);
        predmet->setPos(125+(velikost*52),115);
        scene->addItem(predmet);
    }
    hrac_gui.clear();
    drawPanel(820, 0, 160, pocetHracu * 28, QColor(Qt::gray), 0.90);
    int y_pos;
    switch (hracNaTahu) {
        case 0:
            y_pos = 3;
            break;
        case 1:
            y_pos = 28;
            break;
        case 2:
            y_pos = 54;
            break;
        case 3:
            y_pos = 78;
            break;
    }

    drawPanel(820,y_pos, 160, 25, QColor(Qt::lightGray), 0.90);
    for(int i = 0; i < pocetHracu; i++){
        int radek;
        int sloupec;
        hrac_gui << new Player(i);
        hrac[i].vrat_pozici(&radek,&sloupec);
        int posunx = 70;
        int posuny = 70;
        if(i == 1) {
            posunx = 80;
            posuny = 80;
        }
        else if(i == 2) posuny = 80;
        else if(i == 3) posunx = 80;
        hrac_gui[i]->setPos(posuny+sloupec*52,posunx+radek*52);
        scene->addItem(hrac_gui[i]);

        score = new Score();
        score->vypis(i,hrac[i].pocet_bodu());
        score->setPos(850,i*25);
        scene->addItem(score);
    }

}
/**
 * This function adds all of the necessary components for gameplay in the second task to the scene.
 * @brief RoundOne::start_second_round creates and adds objects of classes Ron, Harry2, Seaweed, and Timer to the scene and starts the timers necessary to begin the second round.
 */
void RoundOne::start_second_round(){
    ///clear the scene and close all other windows
    main_widget->close();
    scene_one->clearFocus();
    scene_one->clear();

    ///create new Ron and add it to the scene
    ron= new Ron();
    scene_one->addItem(ron);

    ///create and add 39 randomly placed seaweeds to the scene, and create and add one right in front of ron
    Seaweed* p1= new Seaweed();
    Seaweed* p2= new Seaweed();
    Seaweed* p3= new Seaweed();
    Seaweed* p4= new Seaweed();
    Seaweed* p5= new Seaweed();
    Seaweed* p6= new Seaweed();
    Seaweed* p7= new Seaweed();
    Seaweed* p8= new Seaweed();
    p9= new Seaweed();
    Seaweed* p10= new Seaweed();
    Seaweed* p11= new Seaweed();
    Seaweed* p12= new Seaweed();
    Seaweed* p13= new Seaweed();
    Seaweed* p14= new Seaweed();
    Seaweed* p15= new Seaweed();
    Seaweed* p16= new Seaweed();
    Seaweed* p17= new Seaweed();
    Seaweed* p18= new Seaweed();
    Seaweed* p19= new Seaweed();
    Seaweed* p20= new Seaweed();
    Seaweed* p21= new Seaweed();
    Seaweed* p22= new Seaweed();
    Seaweed* p23= new Seaweed();
    Seaweed* p24= new Seaweed();
    Seaweed* p25= new Seaweed();
    Seaweed* p26= new Seaweed();
    Seaweed* p27= new Seaweed();
    Seaweed* p28= new Seaweed();
    Seaweed* p29= new Seaweed();
    Seaweed* p30= new Seaweed();
    Seaweed* p31= new Seaweed();
    Seaweed* p32= new Seaweed();
    Seaweed* p33= new Seaweed();
    Seaweed* p34= new Seaweed();
    Seaweed* p35= new Seaweed();
    Seaweed* p36= new Seaweed();
    Seaweed* p37= new Seaweed();
    Seaweed* p38= new Seaweed();
    Seaweed* p39= new Seaweed();
    Seaweed* p40= new Seaweed();

    p9->setPos(ron->pos().x() -10, ron->pos().y()-40);

    ///draw a panel to create a water effect
    drawPanel(0, 0, 800, 600, Qt::darkBlue, 0.70);

    scene_one->addItem(p1);
    scene_one->addItem(p2);
    scene_one->addItem(p3);
    scene_one->addItem(p4);
    scene_one->addItem(p5);
    scene_one->addItem(p6);
    scene_one->addItem(p7);
    scene_one->addItem(p8);
    scene_one->addItem(p9);
    scene_one->addItem(p10);
    scene_one->addItem(p11);
    scene_one->addItem(p12);
    scene_one->addItem(p13);
    scene_one->addItem(p14);
    scene_one->addItem(p15);
    scene_one->addItem(p16);
    scene_one->addItem(p17);
    scene_one->addItem(p18);
    scene_one->addItem(p19);
    scene_one->addItem(p20);
    scene_one->addItem(p21);
    scene_one->addItem(p22);
    scene_one->addItem(p23);
    scene_one->addItem(p24);
    scene_one->addItem(p25);
    scene_one->addItem(p26);
    scene_one->addItem(p27);
    scene_one->addItem(p28);
    scene_one->addItem(p29);
    scene_one->addItem(p30);
    scene_one->addItem(p31);
    scene_one->addItem(p32);
    scene_one->addItem(p33);
    scene_one->addItem(p34);
    scene_one->addItem(p35);
    scene_one->addItem(p36);
    scene_one->addItem(p37);
    scene_one->addItem(p38);
    scene_one->addItem(p39);
    scene_one->addItem(p40);

    ///Give the player 1 minute on the timer to complete the task
    time= new Timer(1, 0);
    scene_one->addWidget(time);
    ///create new Harry2 to the scene
    player2=new Harry2();
    player2->setScale(.25);
    player2-> setPos(365, 300);
    ///make player2 focusable and then set focus
    player2->setFlag(QGraphicsItem::ItemIsFocusable);
    player2->setFocus();

    ///Check every second if the time has run out and the player has lost the game
    othertimer= new QTimer();
    QObject::connect(othertimer, SIGNAL(timeout()), ron, SLOT(lose()));
    othertimer->start(1000);

    ///add player2 to the scene
    scene_one->addItem(player2);

    swimming_music= new QMediaPlayer();
    swimming_music->setMedia(QUrl("qrc:/new/prefix2/UnderwaterSong.m4a"));
    swimming_music->play();

    show();
    ///start the count down timer
    time->timer->start(1000);

}