Ejemplo n.º 1
0
bool CannonField::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0:
        setAngle((int)static_QUType_int.get(_o+1));
        break;
    case 1:
        setForce((int)static_QUType_int.get(_o+1));
        break;
    case 2:
        shoot();
        break;
    case 3:
        newTarget();
        break;
    case 4:
        setGameOver();
        break;
    case 5:
        restartGame();
        break;
    case 6:
        moveShot();
        break;
    default:
        return QWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
Ejemplo n.º 2
0
void MainWindow::doPlay(QString vertex){
    if(game_over) return;
    if(players.getCurrent()->getSpecies() == "Computer"){
        QString result = gtp.genmove( players.getCurrent()->getColorString() );
        if(result == "pass"){
            addHistory(players.currentColor(),tr("Passed"));
            updateScore(players.currentColor(),tr("Passed"));
            players.setCurrentPass();
        }else if( result == "resign"){
            addHistory(players.currentColor(),tr("Resigned"));
            updateScore(players.currentColor(),tr("Resigned"));
            players.setCurrentResigned();
        }else{
            players.setCurrentPlays();
        }
        QString reason = players.getGameOver();
        //if(reason.length()>0) emit gameOver(reason);
        if(reason.length()>0) setGameOver(reason);
    }else{
        if(gtp.play( players.getCurrent()->getColorString(), vertex)){
            players.setCurrentPlays();
        }else{
            addHistory(players.currentColor(),tr("Illegal move, try another"));
            return;
        }
    }
    int cnt= gtp.captures(players.getCurrent()->getColorString());
    if(cnt != players.getCurrent()->getCaptures()){
        players.getCurrent()->setCaptures(cnt);
        ui->gameBoard->checkStones(players.getNext()->getColorString(), gtp.list_stones( players.getNext()->getColorString()));
    }
    afterMove();
}
Ejemplo n.º 3
0
Archivo: STG.cpp Proyecto: Rosalila/STG
void STG::win()
{
    int old_clears = rosalila()->api_integrator->getStat(stage->name+"Clears");
    rosalila()->api_integrator->setStat(stage->name+"Clears",old_clears+1);

    if(player->hp == player->max_hp)
    {
        int old_perfects = rosalila()->api_integrator->getStat(stage->name+"Perfects");
        rosalila()->api_integrator->setStat(stage->name+"Perfects",old_perfects+1);
    }

    setPlayerWon(true);
    setGameOver(true);
    setIsFirstWin(old_clears==0);

    rosalila()->api_integrator->unlockAchievement("B");
    double milliseconds = SDL_GetTicks()-initial_ticks;
    double hp_penalty = (1.0 + ((double)player->max_hp-(double)player->hp)/100.0);
    score = milliseconds * hp_penalty;
    enemy->hp=0;
    rosalila()->graphics->screen_shake_effect.set(50,20,rosalila()->graphics->camera_x,rosalila()->graphics->camera_y);
    rosalila()->sound->playSound("you win", 2, 0, 0, false);
    enemy->deleteActivePatterns();

    if(game_mode!="replay" && (score<current_player_best_score || current_player_best_score==-1))
    {
        uploadScore();
    }
}
bool GameAgent::Game::insertDirection(dir_e dir){
    //m_grid.print(200,50); 
    //std::cout << std::endl << dir  << std::endl;
    if(!m_grid.shift(dir))  return FALSE;

    genNewTile();
    m_moveCnt++;
    setGameOver();
    return TRUE;
}
Ejemplo n.º 5
0
LevelFour::LevelFour() : Stage()
{
	//step("[LevelFour] Constructing.");
	defineBackground();
	generatePlatform();
	generateSecondLayer();
	generateEnemies();
	generateCivilians();
	setFinished(false);
	setGameOver(false);
}
Ejemplo n.º 6
0
void MainWindow::on_buttonResign_clicked()
{
    players.setCurrentResigned();
    addHistory(players.currentColor(),tr("Resigned"));
    updateScore(players.currentColor(),tr("Resigned"));
    QString reason = players.getGameOver();
    if(reason.length()>0) {
        //emit gameOver(reason);
        setGameOver(reason);
    }else{
        afterMove();
    }
}
Ejemplo n.º 7
0
void MainWindow::on_buttonPass_clicked()
{
    if(gtp.pass(players.getCurrent()->getColorString())){
        players.setCurrentPass();
        addHistory(players.currentColor(),tr("Passed"));
        updateScore(players.currentColor(),tr("Passed"));
        QString reason = players.getGameOver();
        if(reason.length()>0){
            //emit gameOver(reason);
            setGameOver(reason);
        }else{
            afterMove();
        }
    }
}
Ejemplo n.º 8
0
void CubeManager::step(float dt)
{
	if (isGameOver())
		return;

	if (!isFallingActive())
	{
		if (!generateFallingBoard())
		{
			setGameOver(true);
		}
		return;
	}

	stepDown();
}
Ejemplo n.º 9
0
int lostLifeMsg( cursorType* cur, playField* pf, SDL_Surface* screen, const char* strmsg, const char* straction )
{
  draw(cur,pf, screen);
  //drawUi(screen);

  countdown-=getTicks();


    txtWriteCenter(screen, GAMEFONTMEDIUM, strmsg, HSCREENW,HSCREENH-24);

    if(countdown < 1000)
    {
      txtWriteCenter(screen, GAMEFONTSMALL, STR_MENU_PRESS_B, HSCREENW,HSCREENH+12);
      //Wait for anykey
      if(getButton(C_BTNB) || countdown < -6000 || getInpPointerState()->isDown )
      {
        resetBtn(C_BTNB);
        resetMouseBtn();
        //Subtract lives
        if(!player()->inEditor)
        {
          if(player()->lives != -1)
          {
            player()->lives--;
          }

          if(player()->lives==0)
          {
            setGameOver();
          } else {
            //Lost a life, but did not get gameover, upload the death
            statsUpload(player()->level, player()->hsEntry.time, player()->hsEntry.moves,player()->hsEntry.combos,player()->hsEntry.score, straction,0, NULL);
            setMenu(menuStateNextLevel);
          }
        }

        //Clear score
          player()->hsEntry.score=0;
        //Goto cleanup, then menu
        cleanUpGame();
        startTransition(screen, TRANSITION_TYPE_ROLL_IN, 700);
        return(1);
      }
    }
    return(0);
}
Ejemplo n.º 10
0
Archivo: STG.cpp Proyecto: Rosalila/STG
void STG::lose()
{
    setPlayerWon(false);
    setGameOver(true);
    rosalila()->sound->playSound("you lose", 4, 0, 0, false);
}
Ejemplo n.º 11
0
Archivo: STG.cpp Proyecto: Rosalila/STG
STG::STG(Player*player,Enemy*enemy,Stage*stage,string game_mode, int current_player_best_score)
{
    this->player=player;
    this->enemy=enemy;
    this->stage=stage;
    this->game_mode=game_mode;
    this->current_player_best_score = current_player_best_score;

    this->api_state = "";

    this->score = -1;

    this->game_over_timeout = 128;

    this->image_upload_error = rosalila()->graphics->getTexture(assets_directory+"misc/upload_error.png");

    this->image_training_box = NULL;
    this->image_training_x = NULL;
    this->image_training_bar = NULL;
    this->image_training_bar_fill = NULL;

    this->player_is_immortal = false;

    rosalila()->graphics->camera_y=0;
    frame=0;

    parry_count=0;
    charge_destroy_count=0;
    parry_dash_count=0;

    current_training_transparency=0;

    //XML Initializations
    string config_directory = assets_directory+"config.xml";
    TiXmlDocument doc_t( (char*)config_directory.c_str() );
    doc_t.LoadFile();
    TiXmlDocument *doc;
    doc=&doc_t;

    TiXmlNode *config_file=doc->FirstChild("ConfigFile");

    TiXmlNode *you_loose_node=config_file->FirstChild("YouLose");

    int you_loose_x=atoi(you_loose_node->ToElement()->Attribute("x"));
    int you_loose_y=atoi(you_loose_node->ToElement()->Attribute("y"));
    int you_loose_animation_velocity=atoi(you_loose_node->ToElement()->Attribute("animation_velocity"));
    you_loose=Animation(you_loose_x,you_loose_y,you_loose_animation_velocity);

    if(you_loose_node->ToElement()->Attribute("sound"))
    {
        rosalila()->sound->addSound("you lose",assets_directory+you_loose_node->ToElement()->Attribute("sound"));
    }

    for(TiXmlNode* sprites_node=you_loose_node->FirstChild("sprite");
            sprites_node!=NULL;
            sprites_node=sprites_node->NextSibling("sprite"))
    {
        std::string path=sprites_node->ToElement()->Attribute("path");
        you_loose.addImage(rosalila()->graphics->getTexture(assets_directory+path));
    }


    TiXmlNode *you_win_node=config_file->FirstChild("YouWin");

    int you_win_x=atoi(you_win_node->ToElement()->Attribute("x"));
    int you_win_y=atoi(you_win_node->ToElement()->Attribute("y"));
    int you_win_animation_velocity=atoi(you_win_node->ToElement()->Attribute("animation_velocity"));
    you_win=Animation(you_win_x,you_win_y,you_win_animation_velocity);

    if(you_win_node->ToElement()->Attribute("sound"))
    {
        rosalila()->sound->addSound("you win",assets_directory+you_win_node->ToElement()->Attribute("sound"));
    }

    for(TiXmlNode* sprites_node=you_win_node->FirstChild("sprite");
            sprites_node!=NULL;
            sprites_node=sprites_node->NextSibling("sprite"))
    {
        std::string path=sprites_node->ToElement()->Attribute("path");
        you_win.addImage(rosalila()->graphics->getTexture(assets_directory+path));
    }

    if(game_mode=="Stage select" || game_mode=="charge training" || game_mode=="parry training" || game_mode=="parry dash training" || "replay")
    {
        stageSelectModeInit();
    }

    if(game_mode=="charge training")
    {
        image_training_bar=rosalila()->graphics->getTexture(assets_directory+"misc/training/bar.png");
        image_training_bar_fill=rosalila()->graphics->getTexture(assets_directory+"misc/training/bar_fill.png");
        charge_destroy_count_objective=300;
        player_is_immortal = true;
    }
    if(game_mode=="parry training")
    {
        image_training_box=rosalila()->graphics->getTexture(assets_directory+"misc/training/box.png");
        image_training_x=rosalila()->graphics->getTexture(assets_directory+"misc/training/x.png");
        parry_count_objective=3;
        player_is_immortal = true;
    }
    if(game_mode=="parry dash training")
    {
        image_training_bar=rosalila()->graphics->getTexture(assets_directory+"misc/training/bar.png");
        image_training_bar_fill=rosalila()->graphics->getTexture(assets_directory+"misc/training/bar_fill.png");
        parry_dash_count_objective=15;
        player_is_immortal = true;
    }

    setGameOver(false);
    setIsFirstWin(false);
    mainLoop();
}