Ejemplo n.º 1
0
extern "C" void Render()
{
    //RenderGradientBackground();
    CreateLight();
    SetupRenderState();

    world.frame++;

    if (world.isTextureMode && world.nextTextureTime>0 && (world.frame % world.nextTextureTime) == 0)
        LoadTexture();

    if (world.frame > world.nextEffectTime)
    {
        if ((rand() % 3)==0)
            incrementColor();
        //static limit = 0;if (limit++>3)
        world.effectType += 1;//+rand() % (ANIM_MAX-1);
        world.effectType %= world.effectCount;
        effects[world.effectType]->reset();
        world.nextEffectTime = world.frame + effects[world.effectType]->minDuration() +
                               rand() % (effects[world.effectType]->maxDuration() - effects[world.effectType]->minDuration());
    }
    effects[world.effectType]->apply();
    world.waterField->Step();
    world.waterField->Render();
    return;
}
Ejemplo n.º 2
0
void HighlightableText::render(RenderPass pass) {
	// Text objects should always be transparent
	if (pass == kRenderPassOpaque)
		return;

	if(isHighlightable() && isHightlighted()) {
		float initialR, initialG, initialB, initialA, r, g, b, a;
		getColor(initialR, initialG, initialB, initialA);
		incrementColor(initialR, initialG, initialB, initialA, r, g, b, a);
		setColor(r, g, b, a);
	}
	Graphics::Aurora::Text::render(pass);
}
Ejemplo n.º 3
0
void TSGame::displayGame()
{
     //Game
    if(levelClock.getElapsedTime().asMicroseconds()/1000.f > 1000.f/level)
    {
        int randomInt {static_cast<int>(getRandomNumber(-1.f,9.f))};
        levelClock.restart();
        auto AI = (randomInt >= 4 ? enemyAILine : enemyAISine);
        randomInt %= 4;
        sf::Vector2f windowSize = transformVector<sf::Vector2u, sf::Vector2f>(mainWindow.getSize());
        sf::Vector2f target {getRandomNumber(0.f, windowSize.x), getRandomNumber(0.f, windowSize.y)};
        sf::Vector2f source;
        switch(randomInt)
        {
        case 0:
            source = sf::Vector2f {-20.f, getRandomNumber(0.f, windowSize.y)};
            break;
        case 1:
            source = sf::Vector2f {windowSize.x+20.f, getRandomNumber(0.f, windowSize.y)};
            break;
        case 2:
            source = sf::Vector2f {getRandomNumber(0.f, windowSize.y), windowSize.x+20.f};
            break;
        case 3:
            source = sf::Vector2f {getRandomNumber(0, windowSize.y), -20.f};
            break;
        default:
            break;
        }
        Enemies.emplace_back(new Enemy {sf::Color::White, source, target, AI});
        levelCounter++;
        if(levelCounter > level * 10)
            level++;
    }

    incrementColor(enemyColor);

    Score = scoreClock.getElapsedTime().asMilliseconds()*level/1000.f;

    for(unsigned int i = 0; i < Enemies.size(); ++i)
    {
        (*Enemies[i]).Update(gameClock.getElapsedTime().asMicroseconds()/1000.f);
        (*Enemies[i]).setColor(enemyColor);
        (*Enemies[i]).render(mainWindow);
        if(collides((*Enemies[i]).getShape().getPosition(), player.getPosition()))
        {
            gameStatus = true;
            Enemies.clear();
            levelCounter = 0;
            level = 1;
            break;
        }
        if((*Enemies[i]).getShape().getPosition().x > mainWindow.getSize().x + 100 ||
                (*Enemies[i]).getShape().getPosition().x < -100 ||
                (*Enemies[i]).getShape().getPosition().y > mainWindow.getSize().y + 100 ||
                (*Enemies[i]).getShape().getPosition().y < -100)
        {
            Enemies.erase(Enemies.begin()+i);
        }
    }
    std::string scoreString {std::to_string(Score)};
    scoreString = scoreString.substr(0, scoreString.find('.')+3);

    textOverlay.setString(std::string {"Level: "} + std::to_string(level) +
                          std::string {"\nScore: "}  + scoreString +
                          std::string {"\nEntities: "} + std::to_string(Enemies.size()));
    mainWindow.draw(textOverlay);
}