Example #1
0
//[5]
void GameField::showField()const
{
    showGreeting();

    /* upper border */
    std::cout << "   ";

    for(int i = 0; i < DEFAULT_FLDSIZE; ++i)
        std::cout << "##";

    std::cout << std::endl;

    /* field + side borders */
    for(int i = 0; i < DEFAULT_FLDSIZE; ++i)
    {
        std::cout << "  #";

        for (int j = 0; j < DEFAULT_FLDSIZE; ++j)
            std::cout << gameField[i][j] << ' ';

         std::cout << "#" << std::endl;
    }

    /* bottom border */
    std::cout << "   ";

    for(int i = 0; i < DEFAULT_FLDSIZE; ++i)
        std::cout << "##";

    std::cout << std::endl;

    showScore();
    showLevel();
}
void CPullMachPrizeRemainFontNode::updateScoreSchedule(float dt)
{
	//更新分数
	if (m_bAddScore)
	{
		m_lNowScore += m_lEachUpdateScore;
		if (m_lNowScore >= m_lDestScore)
		{
			m_lNowScore = m_lDestScore;
			m_bUpdating = false;
			unschedule(schedule_selector(CPullMachPrizeRemainFontNode::updateScoreSchedule));
		}
	}
	else
	{
		m_lNowScore -= m_lEachUpdateScore;
		if (m_lNowScore <= m_lDestScore)
		{
			m_lNowScore = m_lDestScore;
			m_bUpdating = false;
			unschedule(schedule_selector(CPullMachPrizeRemainFontNode::updateScoreSchedule));
		}
	}

	//显示分数
	showScore(m_lNowScore);
}
Example #3
0
void checkLines(int *score)
{
  int row, col, row2;

  for(row = 13; row >= 0; )
  {
    for(col = 1; col <= 10; col++)
    if(crt[row][col] != 'X')
        break;

    if(col == 11)  // all X's
    {
      *score += 100;

      for(row2 = row - 1; row2 >= 0; row2--)
        for(col = 1; col <= 10; col++)
            putChar(crt[row2][col], col, row2 + 1);

      for(col = 1; col <= 10; col++)
        putChar(' ', col, 0);  // clear top row

      showScore(*score);
    } // if all X's on this row
    else
      row--;
  } // for each row
} // checkLines()
Example #4
0
void mathGame::gameMenu(){
	char start;
	cout << "[S]tart Game [H]igh Scores [Q]uit Game" << endl;
	cin >> start; cin.ignore(100, '\n');
	start = toupper(start);
	
	
		
		switch (start)
		{
		case 'S':
			while (stop(problemGenerator()))
			{
				showScore();
			}
			gameMenu();
			break;
		case 'H':
			setHighScore();
			gameMenu();
			break;
		case 'Q':
			break;
		default:
			cout << "Oops something happended!?" << endl;
			break;
		}
	



}
int hitCentipede(Centipede centipedes[], int sparkXs[], int counts[14][38],
  int *score, int *bodyCount, int y)
{
  int i, y1 = y - 1;

  if(crt[y1][sparkXs[y]] == BODY)
    *score += BODY_POINTS;
  else
    *score += HEAD_POINTS;

  showScore(*score);

  for(i = 0; i < 6; i++)  // find centipede part that matches spark location
    if(centipedes[i].x == sparkXs[y] && centipedes[i].y == y1)
      break;

  centipedes[i++].icon = NO_BODY;

  if(i < 6 && centipedes[i].icon == BODY)  // next part
  {
    if(centipedes[i].direction == RIGHT)
      centipedes[i].icon = RIGHT_HEAD;
    else
      centipedes[i].icon = LEFT_HEAD;

    putChar(centipedes[i].icon, centipedes[i].x, centipedes[i].y);
  } // if next body part is not a head

  putChar(MUSHROOM, sparkXs[y], y1);
  counts[y1][sparkXs[y]] = 4;
  --(*bodyCount);
} // hitCentipede()
Example #6
0
void CGameMessage::update(float dt)
{
	showScore();
	showHp();
	showLife();
	showMissile();
}
Example #7
0
void ShootEmUp::gain(int8 howMuch) {
	if ((_score + howMuch) < 0) // howMuch can be negative!
		_score = 0;
	else
		_score += howMuch;

	showScore();
}
Example #8
0
void Game::showInfos()
{
	showNextPiece();
	showHoldPiece();
	showScore();
	showLevel();
	showLinesCompleted();
	showBestScore();
}
//初始化各项数据
void Over::initData()
{
    //加载背景
    loadBackground();
    //显示得分
    showScore();
    //加载菜单
    loadMenu();
}
void GameWidget::timerEvent(QTimerEvent *timerEvent)
{
    //Vérifie si la partie a déjà commencé ou non
    if(m_preStartTimer->timeRemaining())
    {
        m_timeBeforeStartLabel.setText(QString::number(m_preStartTimer->timeRemaining()));
    }
    else{
        //Vérifie si le jeu est en pause ou non
        if(!m_paused)
        {
            if (m_scene)
            {
                //Vérifie si le jeu est en pause
                if(m_scene->isFinished())
                {
                    killTimer(timerEvent->timerId());
                    emit showScore("EndGame");
                }
                //Gère les actions dans le cas où la partie est en cours
                else
                {
                    /// mise à jour de la scène
                    m_scene->update();

                     /// mise à jour de la caméra
                    View view = m_scene->calcViewPoint();
                    centerOn(view.position());
                    // "crante" l'effet de zoom, car visiblement, changer l'échelle de la vue dans qt prend du temps
                    // et ralenti considérablement le jeu lorsque cela est fait à chaque frame.
                    //float zoom = (int)(view.zoom()*200)/200.f;
                    //std::cout << view.zoom() << " --- " << zoom << " --- " << m_cameraScale << std::endl;
                    //view.setZoom(.7);
                    m_frameCount++;
                    if (m_frameCount == 3)
                        m_frameCount = 0;
                    if (m_frameCount == 0)
                    {
                        if (view.zoom() != m_cameraScale)
                        {
                            float cameraScale = 1 - (m_cameraScale - view.zoom());
                            m_cameraScale = view.zoom();
                            scale(cameraScale, cameraScale);
                        }
                    }

                    /// mise à jour du compteur (Affichage
                    m_timeLabel.setText(utils::showableTime(m_scene->time().elapsed()));

                    /// mise à jour du nombre de checkpoint restant (Affichage)
                    QString checkpointRemainingString = "Checkpoint(s) Remaining : "+QString::number(m_scene->checkpointListener()->checkpointRemaining());
                    m_checkpointRemainingLabel.setText(checkpointRemainingString);
                }
            }
        }
    }
}
void MainWindow::showEvent(QShowEvent *)
{
    // Setting the QGraphicsScene
    scene = new QGraphicsScene(0,0,width()*2,height()*2);
    QPixmap bg;
    bg.load(":/image/backgroung.png");
    bg = bg.scaled(width()*2,height()*2);
    scene->addPixmap(bg);
    ui->graphicsView->setScene(scene);
    ui->graphicsView-> scale(0.5,0.5);
    for(int i=0;i<10;i++){
        scorenumberPic[i].load("://image/number_"+QString::number(i)+".png");
        scorenumberPic[i]=scorenumberPic[i].scaled(scorenumberPic[i].width()*4,scorenumberPic[i].height()*4);
    }
    button = new QPushButton("",this);
    QPixmap icon;
    icon.load(":/image/restart.png");
    icon = icon.scaled(800,800);
    button->setIcon(icon);
    button->setIconSize(QSize(70,70));
    button->setGeometry(10,10,70,70);
    button->setFlat(true);
    button->show();
    connect(button,SIGNAL(clicked(bool)),this,SLOT(restart()));

    button1 = new QPushButton("",this);
    icon.load(":/image/exit.png");
    icon = icon.scaled(800,800);
    button1->setIcon(icon);
    button1->setIconSize(QSize(70,70));
    button1->setGeometry(100,10,70,70);
    button1->setFlat(true);
    button1->show();
    connect(button1,SIGNAL(clicked(bool)),this,SLOT(quitgame()));

    // Create world
    world = new b2World(b2Vec2(0.0f, -9.8f));
    world->SetContactListener(&listener);
    // Setting Size
    GameItem::setGlobalSize(QSizeF(32,18),size());
    // Create ground (You can edit here)
    itemList.push_back(new Land(32,-17,64,0,QPixmap(":/ground.pn").scaled(width()*2,height()/6.0),world,scene));
    //itemList.push_back(new Land(32,1.5,3,35,QPixmap(":/ground.pn").scaled(width(),height()/6.0),world,scene));//r bound
    //itemList.push_back(new Land(0,1.5,3,35,QPixmap(":/ground.pn").scaled(width(),height()/6.0),world,scene));//l bound
    createStage();
    createBird(blue);
    // Timer
    connect(&timer,SIGNAL(timeout()),this,SLOT(tick()));
    connect(&timer,SIGNAL(timeout()),this,SLOT(showScore()));
    timer.start(100/6);
    connect(this,SIGNAL(quitGame()),this,SLOT(QUITSLOT()));

    connect(&timer_z,SIGNAL(timeout()),this,SLOT(zoomIn()));
    connect(&timer_f,SIGNAL(timeout()),this,SLOT(followBird()));
    connect(&timer_waiter,SIGNAL(timeout()),this,SLOT(createBird()));
}
Example #12
0
//倒數計時器SLOT
void MainWindow::countDownThirty()
{
    counter->setText(QString::number(countTime));
    countTime-=1;
    if(countTime==-2){
        countTime=30;
        countDownTimer->stop();
        showScore();
    }
}
void hitMushroom(int sparkXs[], int counts[14][38], int *score, int y)
{
  int y1 = y - 1;
  --counts[y1][sparkXs[y]];

  if(counts[y1][sparkXs[y]] == 0) // destroyed mushroom
  {
    *score += MUSHROOM_POINTS;
    putChar(' ', sparkXs[y], y1); // remove mushroom
  } // if destroyed a mushroom

  showScore(*score);
} // hitMushroom()
void CPullMachPrizeRemainFontNode::setScore(LONGLONG lScore)
{
	//参数校验
	CC_ASSERT(lScore >= 0);
	if (lScore < 0)
		lScore = 0;

	if (m_bUpdating)
	{
		unschedule(schedule_selector(CPullMachPrizeRemainFontNode::updateScoreSchedule));
		m_bUpdating = false;
	}

	m_lNowScore = lScore;
	m_lDestScore = lScore;
	showScore(lScore);
}
TrayIcon::TrayIcon(QmlView * view, QObject *parent) :
    QSystemTrayIcon(parent)
{
    this->view = view;
    QMenu * menu = new QMenu();
    menu->addAction((tr("&End of day")), this, SLOT(showScore()));
    menu->addSeparator();
    menu->addAction(tr("&Tick"), this, SLOT(showTick()));
    menu->addAction(tr("&Manage..."), this, SLOT(showManage()));
    menu->addSeparator();
    menu->addAction(tr("&About"), this, SLOT(showAbout()));
    menu->addAction(tr("About &Qt"), this, SLOT(showAboutQt()));
    menu->addAction(tr("Exit"), this, SLOT(exitApp()));
    setContextMenu(menu);

    this->setIcon(QIcon(":/Gupaa.png"));
}
void startNewScreen(Centipede centipedes[], int counts[14][38], int sparkXs[14],
  int score, int wandX, int *bodyCount)
{
  int i, j, direction, x, y;
  char str[10];

  erase();  // clear screen completely
  for(x = 0; x < 38; x++)
    for(y = 0; y < 14; y++)
    {
      crt[y][x] = ' ';
      counts[y][x] = 0;
    } // for y

  mvaddstr(0,0,"----------------------------------------");

  for(y = 1; y < 15; y++)
    mvaddstr(y, 0, "|                                      |");

  mvaddstr(15,0,"----------------------------------------");
  mvaddstr(16,0,"Borders are not in CUSP");
  showScore(score);

  for(i = 0; i < 14; i++)
    sparkXs[i] = NO_SPARK;  // no spark at each row

  startCentipede(centipedes, bodyCount);

  for(i = 0; i < 20; i++)
  {
    y = random2(11) + 1;
    x = random2(37);
    random2(5); // to avoid having all y's even and x's odd
    putChar(MUSHROOM, x, y);
    counts[y][x] = 4;
  }

  putChar(WAND, wandX, BOTTOM);
  refresh();
} // StartNewScreen()
Example #17
0
void startNewScreen(int score, Tetromino *tetromino)
{
  int x, y;

  erase();  // clear screen completely
  for(x = 0; x < 38; x++)
    for(y = 0; y < 14; y++)
      crt[y][x] = ' ';

  mvaddstr(0,0,"------------");
  mvaddstr(1,14, "Score:");

  for(y = 0; y < 14; y++)
  {
    putChar('|', 0, y);
    putChar('|', 11, y);
  } // for y

  mvaddstr(15,0,"------------");
  mvaddstr(16,0,"Horizontal borders are not in CUSP");
  showScore(score);
  startTetromino(tetromino);
  refresh();
} // StartNewScreen()
Example #18
0
void ShootEmUp::setup() {
	_vm->_graphics->blackOutScreen();

	newEscape();

	for (int i = 0; i < 7; i++) {
		_stockStatus[i] = _vm->_rnd->getRandomNumber(1);
		showStock(i);
	}

	// Set up status line:
	_vm->_graphics->seuDrawPicture(0, 0, 16); // Score:
	showScore(); // Value of score (00000 here).
	_vm->_graphics->seuDrawPicture(110, 0, 19); // Time:
	showTime(); // Value of time.

	_vm->_graphics->refreshScreen();

	// From the original core cycle:
	initRunner(20, 70, 48, 54, _vm->_rnd->getRandomNumber(4) + 1, _vm->_rnd->getRandomNumber(3) - 2);
	initRunner(600, 70, 48, 54, _vm->_rnd->getRandomNumber(4) + 1, _vm->_rnd->getRandomNumber(3) - 2);
	initRunner(600, 100, 61, 67, (-(int8)_vm->_rnd->getRandomNumber(4)) + 1, _vm->_rnd->getRandomNumber(3) - 2);
	initRunner(20, 100, 61, 67, (-(int8)_vm->_rnd->getRandomNumber(4)) + 1, _vm->_rnd->getRandomNumber(3) - 2);
}
Example #19
0
void resetBonusScore() {
  bonusScore = 10;
  showScore();
}
Example #20
0
static void missBonus() {
  bonusScore /= 20;
  bonusScore *= 10;
  if ( bonusScore < 10 ) bonusScore = 10;
  showScore();
}
Example #21
0
 void handleClick(int opt)
 {
 if(gamestate==0)//Main menu
 {
 switch(opt)
 {
 case 0://quit
 done=true;
 break;
 case 2://Hard
 gamestate=3;
 generateHardQuestion();
 break;
 case 3:
 gamestate=2;
 generateMediumQuestion();//Medium
 break;
 case 4://Easy
 gamestate=1;
 generateEasyQuestion();
 break;
 }
 }
 else if(gamestate==1||gamestate==2||gamestate==3)//Easy,Medium,Hard
 {
 if(opt==-1)return;//If no option was clicked, do nothing
 if(options[opt].state==true)return;//TODO-fix problems //If the question was clicked, do nothing
 if(strcmp(answer,options[opt].string)!=0)//If the wrong answer was clicked, remove it and deduct score
 {
 removeOption(opt);
 score--;
 }
 else
 {
 score++; //Increase score and generate next question
 if(gamestate==1)
 {
 generateEasyQuestion();
 }
 else if(gamestate==2)
 {
 generateMediumQuestion();
 }
 else if(gamestate==3)
 {
 generateHardQuestion();
 }
 if(questions==26)
 {
 questions=0;
 gamestate=4;
 showScore();
 }
 }
 }
 else if(gamestate==4)
 {
 if(opt==0)
 {
 score=0;
 gamestate=0;
 displayMainMenu();
 }
 }
 }