コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: Vourhey/MineSweeper
void MainWindow::createActs()
{
    newAct = new QAction(tr("New"), this);
    newAct->setShortcut(QKeySequence::New);
    connect(newAct, SIGNAL(triggered()), m_field, SLOT(newGame()));

    pauseAct = new QAction(tr("Pause"), this);
    pauseAct->setCheckable(true);
    pauseAct->setShortcut(Qt::Key_P);
    connect(pauseAct, SIGNAL(toggled(bool)), m_field, SLOT(pause(bool)));

    showHighScoreAct = new QAction(tr("Show High Scores"), this);
    connect(showHighScoreAct, SIGNAL(triggered()), SLOT(showHighScore()));

    quitAct = new QAction(tr("Quit"), this);
    quitAct->setShortcut(QKeySequence::Quit);
    connect(quitAct, SIGNAL(triggered()), SLOT(close()));

    showToolbarAct = new QAction(tr("Show Toolbar"), this);
    showToolbarAct->setCheckable(true);
    showToolbarAct->setChecked(true);

    showStatusbarAct = new QAction(tr("Show Statusbar"), this);
    showStatusbarAct->setCheckable(true);
    showStatusbarAct->setChecked(true);

    easyAct = new QAction(tr("Easy"), this);
    easyAct->setCheckable(true);
    easyAct->setData(1);
    connect(easyAct, SIGNAL(triggered()), m_field, SLOT(setDifficulty()));

    mediumAct = new QAction(tr("Medium"), this);
    mediumAct->setCheckable(true);
    mediumAct->setData(2);
    connect(mediumAct, SIGNAL(triggered()), m_field, SLOT(setDifficulty()));

    hardAct = new QAction(tr("Hard"), this);
    hardAct->setCheckable(true);
    hardAct->setData(3);
    connect(hardAct, SIGNAL(triggered()), m_field, SLOT(setDifficulty()));

    customAct = new QAction(tr("Custom"), this);
    customAct->setCheckable(true);
    customAct->setData(4);
    connect(customAct, SIGNAL(triggered()), m_field, SLOT(setDifficulty()));

    QActionGroup *actGroup = new QActionGroup(this);
    actGroup->addAction(easyAct);
    actGroup->addAction(mediumAct);
    actGroup->addAction(hardAct);
    actGroup->addAction(customAct);
    easyAct->setChecked(true);

    aboutAct = new QAction(tr("About"), this);
    aboutAct->setShortcut(QKeySequence::HelpContents);
    connect(aboutAct, SIGNAL(triggered()), SLOT(aboutSlot()));
}
コード例 #2
0
ファイル: ProofCreate.cpp プロジェクト: 619213152/vpal20
// {
//   // if either of these parameters is set, a custom generator is used
//   difficulty: <number>       // optional
//   secret: <secret>           // optional
// }
Json::Value doProofCreate (RPC::Context& context)
{
    // XXX: Add ability to create proof with arbitrary time
    Json::Value     jvResult (Json::objectValue);

    if (context.params_.isMember ("difficulty") ||
        context.params_.isMember ("secret"))
    {
        // VFALCO TODO why aren't we using the app's factory?
        auto pgGen = make_ProofOfWorkFactory ();

        if (context.params_.isMember ("difficulty"))
        {
            if (!context.params_["difficulty"].isIntegral ())
                return RPC::invalid_field_error ("difficulty");

            int const iDifficulty (context.params_["difficulty"].asInt ());

            if (iDifficulty < 0 ||
                iDifficulty > ProofOfWorkFactory::kMaxDifficulty)
            {
                return RPC::invalid_field_error ("difficulty");
            }

            pgGen->setDifficulty (iDifficulty);
        }

        if (context.params_.isMember ("secret"))
        {
            uint256 uSecret (context.params_["secret"].asString ());
            pgGen->setSecret (uSecret);
        }

        jvResult["token"] = pgGen->getProof ().getToken ();
        jvResult["secret"] = to_string (pgGen->getSecret ());
    }
    else
    {
        jvResult["token"]
                = getApp().getProofOfWorkFactory ().getProof ().getToken ();
    }

    return jvResult;
}
コード例 #3
0
 void D3_Progression::setInferno( QVariant _inferno )
 {
     setDifficulty( _inferno, e_Inferno );
 }
コード例 #4
0
 void D3_Progression::setHell( QVariant _hell )
 {
     setDifficulty( _hell, e_Hell );
 }
コード例 #5
0
 void D3_Progression::setNightmare( QVariant _nightmare )
 {
     setDifficulty( _nightmare, e_Nightmare );
 }
コード例 #6
0
 // setFunction
 void D3_Progression::setNormal( QVariant _normal )
 {
     setDifficulty( _normal, e_Normal );
 }
コード例 #7
0
ファイル: PlayState.cpp プロジェクト: DrJonki/Ludum-Dare-30
bool ld::PlayState::init()
{
    std::srand(static_cast<unsigned int>(std::time(0)));
    
    if (m_music.openFromFile("assets/Audio/Music/Abstraction - Ludum Dare 28 - First Track.wav"))
        m_music.play();
    m_music.setLoop(true);

    const float buttonScale = 2.f;
    // Pause menu
    {
        std::array<std::unique_ptr<Button>, 3> buttons;

        for (auto& i : buttons)
        {
            i.reset(new Button(*m_window));

            i->setFillColor(sf::Color(255, 255, 255, 255));
            i->setSound("assets/Audio/Sound Effects/menuselect.ogg");
        }
        const float buttonOffset = 50.f;

        /****** Resume button ******/
        auto tex = ldResource.getTexture("assets/Graphics/Menus/retry.png");
        buttons[0]->setTexture(tex);
        buttons[0]->setSize(sf::Vector2f(tex->getSize()) * buttonScale);
        buttons[0]->setPosition(100.f, 100.f);
        buttons[0]->setCallback([this]()
        {
            m_menuState = Count;
            Engine::getInstance().setPaused(false);
        });

        /****** Restart button ******/
        tex = ldResource.getTexture("assets/Graphics/Menus/restart.png");
        buttons[1]->setTexture(tex);
        buttons[1]->setSize(buttons[0]->getSize());
        buttons[1]->setPosition(100.f, buttons[0]->getPosition().y + buttons[0]->getSize().y + buttonOffset);
        buttons[1]->setCallback([this]()
        {
            auto ptr = new PlayState(*m_window);
            ptr->setDifficulty(m_difficulty);
            Engine::getInstance().changeState(ptr);
            Engine::getInstance().setPaused(false);
        });

        /****** Exit button ******/
        tex = ldResource.getTexture("assets/Graphics/Menus/backToMenu.png");
        buttons[2]->setTexture(tex);
        buttons[2]->setSize(buttons[1]->getSize());
        buttons[2]->setPosition(100.f, buttons[1]->getPosition().y + buttons[1]->getSize().y + buttonOffset);
        buttons[2]->setCallback([this]()
        {
            Engine::getInstance().changeState(new MainMenuState(*m_window));
            Engine::getInstance().setPaused(false);
        });

        for (auto& i : buttons)
            m_menus[Pause]->addElement(i.release());
    }

    // Game over menu
    {
        std::array<std::unique_ptr<Button>, 2> buttons;

        for (auto& i : buttons)
        {
            i.reset(new Button(*m_window));

            i->setFillColor(sf::Color(255, 255, 255, 255));
            i->setSound("assets/Audio/Sound Effects/menuselect.ogg");
        }

        const float buttonOffset = 50.f;

        /****** Restart button ******/
        auto tex = ldResource.getTexture("assets/Graphics/Menus/restart.png");
        buttons[0]->setTexture(tex);
        buttons[0]->setSize(sf::Vector2f(tex->getSize()) * buttonScale);
        buttons[0]->setPosition(100.f, 100.f);
        buttons[0]->setCallback([this]()
        {
            auto ptr = new PlayState(*m_window);
            ptr->setDifficulty(m_difficulty);

            Engine::getInstance().changeState(ptr);
            Engine::getInstance().setPaused(false);
        });

        /****** Quit button ******/
        tex = ldResource.getTexture("assets/Graphics/Menus/backToMenu.png");
        buttons[1]->setTexture(tex);
        buttons[1]->setSize(buttons[0]->getSize());
        buttons[1]->setPosition(100.f, buttons[0]->getPosition().y + buttons[0]->getSize().y + buttonOffset);
        buttons[1]->setCallback([this]()
        {
            Engine::getInstance().changeState(new MainMenuState(*m_window));
            Engine::getInstance().setPaused(false);
        });

        for (auto& i : buttons)
            m_menus[GameOver]->addElement(i.release());
    }

	//Player
	auto tex = ldResource.getTexture("assets/Graphics/Player and shield planets/Player_Base.png");
	tex->setSmooth(true);
	m_player.setTexture(tex);
	m_player.setSize(sf::Vector2f(128.f,128.f));
	m_player.setOrigin(m_player.getSize().x / 2, m_player.getSize().y / 2);
	m_player.setPosition(m_window->getView().getCenter());

	tex = ldResource.getTexture("assets/Graphics/Player and shield planets/Shield.png");
	tex->setSmooth(true);
	m_player.m_shield.setTexture(tex);
	m_player.m_shield.setSize(sf::Vector2f(128.f, 128.f));
	m_player.m_shield.setOrigin(m_player.m_shield.getSize().x / 2, m_player.m_shield.getSize().y / 2);
	m_player.m_shield.setPosition(m_player.getPosition() - m_player.getSize());

	tex = ldResource.getTexture("assets/Graphics/Effects/electricity_chain_loop.png");
	tex->setSmooth(true);
	tex->setRepeated(true);
	m_player.m_chain.setTexture(tex);
	m_player.m_chain.setSize(sf::Vector2f(200, 200));
	m_player.m_chain.setOrigin(m_player.m_chain.getSize().x / 2, 0);
	m_player.m_chain.setPosition(m_player.getPosition());

    tex = ldResource.getTexture("assets/Graphics/Player and shield planets/Player_Cloud.png");
    tex->setSmooth(true);
    m_player.m_clouds.setTexture(tex);
    m_player.m_clouds.setSize(m_player.getSize());
    m_player.m_clouds.setScale(m_player.getScale());
    m_player.m_clouds.setOrigin(m_player.getSize() / 2.f);
    m_player.m_clouds.setPosition(m_player.getPosition());
	
    tex = ldResource.getTexture("assets/Graphics/Backgrounds/background.png");
    tex->setSmooth(true);
    m_background.setSize(m_window->getView().getSize());
    m_background.setTexture(tex);

    tex = ldResource.getTexture("assets/Graphics/Menus/healthcounter.png");
    tex->setSmooth(true);
    m_lifeIcon.setTexture(tex);
    m_lifeIcon.setSize(sf::Vector2f(m_lifeIcon.getTexture()->getSize()));

    tex = ldResource.getTexture("assets/Graphics/Menus/killcounter.png");
    tex->setSmooth(true);
    m_killIcon.setTexture(tex);
    m_killIcon.setSize(sf::Vector2f(m_killIcon.getTexture()->getSize()));

    auto font = ldResource.getFont("assets/Graphics/Roboto-Black.ttf");
    m_scoreText.setFont(*font);
    m_scoreText.setCharacterSize(50);
    m_scoreText.setColor(sf::Color(255, 255, 255, 255));

    m_killsText.setFont(*font);
    m_killsText.setCharacterSize(65);
    m_killsText.setColor(sf::Color(255, 255, 255, 255));

    switch (m_difficulty)
    {
        case 1:
            m_Time = 6.f;
            m_minTime = 3.f;
			m_player.setLives(5);
			m_enemySpeed = 150.f;
			m_enemySpeedMin = 100.f;
			break;
        case 2:
            m_Time = 3.5f;
            m_minTime = 1.f;
            m_player.setLives(4);
			m_enemySpeed = 185.f;
			m_enemySpeedMin = 100.f;
            break;
        case 3:
            m_Time = 2.5f;
            m_minTime = 0.25f;
			m_player.setLives(3);
			m_enemySpeed = 225.f;
			m_enemySpeedMin = 100.f;
            break;
		default:
			assert(false);
			break;
    }

    m_scoreClock.restart();

	//Enemy
	addEnemy();

	return true;
}
コード例 #8
0
void BossSpellWorker::Reset(uint8 _Difficulty)
{
    currentDifficulty = setDifficulty(_Difficulty);
    resetTimers();
};
コード例 #9
0
void Settings::setDifficulty(Difficulty newDifficulty)
{
    setDifficulty((int)newDifficulty);
}
コード例 #10
0
/*
 * Executes a command given by the user
 *
 * @params: (command) - the command given by the user
 * @return: relevant exitcode
 */
int executeCommand(char* command){
	char str[64];
	sscanf(command, "%s", str);
	if (str_equals(str, "quit")){
		exit(0);
	}	
	if (state == SETTINGS){
		if (str_equals(str, "game_mode")){
			return setGameMode(command);
		}
		if (str_equals(str, "difficulty")){
			return setDifficulty(command);
		}
		if (str_equals(str, "user_color")){
			return setUserColor(command);
		}
		if (str_equals(str, "load")){
			return loadGameByCommand(command);
		}
		if (str_equals(str, "clear")){
			Board_clear(&board);
			PieceCounter_reset(counter);
			return 0;
		}
		if (str_equals(str, "next_player")){
			return setFirstPlayer(command);
		}
		if (str_equals(str, "rm")){
			return removePiece(command);
		}
		if (str_equals(str, "set")){
			return setPiece(command);
		}
		if (str_equals(str, "print")){
			display();
			return 0;
		}
		if (str_equals(str, "start")){
			if(PieceCounter_kingIsMissing(counter)){
				return -7;
			}	
			turn = first;
			state = GAME;
			return 2; //special value to break the humanTurn loop so the initial board will always be checked for immediate loss or tie conditions
		}
	}
	else{
		if (str_equals(str, "get_moves")){
			return printMovesOfPiece(command);
		}
		if (str_equals(str, "move")){
			return movePiece(command);
		}
		if (str_equals(str, "castle")){
			return castleRook(command);
		}
		if (str_equals(str, "get_best_moves")){
			return printBestMoves(command);
		}
		if (str_equals(str, "get_score")){
			return printMoveValue(command);
		}	
		if (str_equals(str,"save")){
			return saveGameByCommand(command);
		}
	}
	return -1;
}