本文整理汇总了C++中sf::RectangleShape::setTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ RectangleShape::setTexture方法的具体用法?C++ RectangleShape::setTexture怎么用?C++ RectangleShape::setTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::RectangleShape
的用法示例。
在下文中一共展示了RectangleShape::setTexture方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintLighting
void cWindow::paintLighting()
{
float power;
int tex;
int lightsDisplayed = 0;
int priority = 0;
for (int a = 0; a < 2; a++)
{
priority = 0;
while (priority < LIMIT_PRIORITY_LIGHT && lightsDisplayed < game.unitCounter)
{
for (int i = 0; i < game.unitCounter; i++)
{
if (game.unit[i].light.priority == priority && game.unit[i].light.power > 0 && game.unit[i].light.texture != -1)
{
tex = game.unit[i].light.texture;
brushRect.setTexture(&visual.gameTex[tex].handle);
brushRect.setPosition(game.unit[i].pos);
brushRect.setFillColor(sf::Color(255, 255, 255, max(0.00f, min(255.00f, 300.00f - game.ambientLight))));
if (!settings.enableDynamicLight) {
brushRect.setTexture(&visual.gameTex[visual.addTexture("light_white.png")].handle);
brushRect.setFillColor(sf::Color(255, 255, 255, 50.00f));
}
brushRect.setTextureRect(sf::IntRect(0, 0, visual.gameTex[tex].handle.getSize().x, visual.gameTex[tex].handle.getSize().y));
power = game.unit[i].light.power;
if (game.unit[i].light.flickerMod != 0.00f) {
power += power * (game.unit[i].light.flickerMod * abs(game.unit[i].light.flickerCurTime / game.unit[i].light.flickerTime - 1.00f));
power += math.randf(-5.00f, 5.00f);
}
brushRect.setOrigin(sf::Vector2f(power, power));
brushRect.setSize(sf::Vector2f(power * 2.00f, power * 2.00f));
// Directional
brushRect.setRotation(0.00f);
if (game.unit[i].light.directional) {
brushRect.setRotation(-game.unit[i].facingAngle);
}
// Painting to two textures
if (settings.enableDynamicLight && a == 0) { window.texHandleLight.draw(brushRect, window.matrixHandle); }
else if (settings.enableDynamicLight && a == 1) { window.texHandleLightMult.draw(brushRect, window.matrixHandle); }
else { window.texHandle.draw(brushRect, window.matrixHandle); }
}
}
priority += 1;
}
if (!math.intToBool(settings.enableBetterLight)) { break; }
}
brushRect.setRotation(0.00f);
window.texHandleLight.display();
if (settings.enableBetterLight) { window.texHandleLightMult.display(); }
}
示例2: main
int main() {
sgb::Chip8 chip8;
chip8.loadGame("PONG2");
back.create(64, 32, sf::Color::Black);
backshape.setPosition(0, 0);
backtext.loadFromImage(back);
backshape.setTexture(&backtext);
while(window.isOpen()){
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
// emulate one cycle
chip8.emulateCycle();
// if drawflag is set, update screen;
if (chip8.drawFlag)
updateGraphics(chip8);
//query keys
chip8.setKeys();
sf::sleep(sf::seconds(1.0f/500.0f));
}
return 0;
}
示例3: paintClouds
void cWindow::paintClouds()
{
brushRect.setScale(vec2f(1.00f, 1.00f));
brushRect.setFillColor(color(0, 0, 0));
//brushRect.setTexture(&visual.gameTex[database.texture[TEX_CLOUD]].handle);
sf::FloatRect camRect(camera.pos.x, camera.pos.y, camera.res.x, camera.res.y);
mutex.renderClouds.lock();
visual.cloudsPainted = 0;
for (int i = 0; i < (int)weather.cloud.size(); i++)
{
//brushRect.setTexture(&weather.cloudTexture[i], true);
brushRect.setTexture(&visual.gameTex[weather.cloud[i].tex].handle, true);
brushRect.setPosition(weather.cloud[i].pos);
brushRect.setSize(weather.cloud[i].size);
brushRect.setOrigin(weather.cloud[i].size / 2.00f);
if (camRect.intersects(brushRect.getGlobalBounds())) {
window.texHandleShadow.draw(brushRect, window.matrixHandle);
visual.cloudsPainted += 1;
}
}
mutex.renderClouds.unlock();
}
示例4: paintParticles
void cWindow::paintParticles()
{
cParticleUnit* unit;
float shadowBrightness = (game.ambientLight - 150.00f) / 255.00f * 210.00f;
shadowBrightness = max(0.00f, min(255.00f, shadowBrightness));
if (!settings.enableParticleShadows) { shadowBrightness = 0.00f; }
visual.particlesPainted = 0;
mutex.renderParticles.lock();
int repeats = 1;
if (settings.enableParticleShadows && settings.enableBetterParticleShadows) { repeats += 1; }
for (int a = 0; a < repeats; a++)
{
for (int i = 0; i < (int)particle.unit.size(); i++)
{
// Setup
unit = &particle.unit[i];
brushRect.setSize(unit->size * 0.50f * (unit->lifetime / unit->lifetimeMax) + unit->size * 0.50f);
brushRect.setOrigin(unit->size / 2.00f);
if (i == 0 || particle.unit[i].type != particle.unit[i - 1].type)
{
brushRect.setTexture(&visual.gameTex[unit->texture].handle, true);
}
// Display
float transpar = (unit->fadeVal / unit->fadeMax);
if (a == 0)
{
if (shadowBrightness > 0.00f && settings.enableParticleShadows && !settings.enableBetterParticleShadows)
{
brushRect.setPosition(unit->shadowPos);
brushRect.setFillColor(color(0, 0, 0, shadowBrightness * transpar));
window.texHandle.draw(brushRect, window.matrixHandle);
}
brushRect.setPosition(unit->pos);
brushRect.setFillColor(color(255, 255, 255, 255 * transpar));
window.texHandle.draw(brushRect, window.matrixHandle);
visual.particlesPainted += 1;
}
else if (a == 1)
{
brushRect.setPosition(unit->shadowPos);
brushRect.setFillColor(color(0, 0, 0, 255 * transpar));
window.texHandleShadow.draw(brushRect, window.matrixHandle);
if (settings.enablePreciseParticleShadows)
{
brushRect.setPosition(unit->pos);
brushRect.setFillColor(color(255, 255, 255, 255 * transpar));
window.texHandleShadow.draw(brushRect, window.matrixHandle);
}
}
}
}
mutex.renderParticles.unlock();
/*for (int i = 0; i < (int)particle.unit.size(); i++)
{
// Setup
unit = &particle.unit[i];
brushRect.setSize(unit->size * 0.50f * (unit->lifetime / unit->lifetimeMax) + unit->size * 0.50f);
brushRect.setOrigin(unit->size / 2.00f);
if (i == 0 || particle.unit[i].type != particle.unit[i - 1].type)
{
brushRect.setTexture(&visual.gameTex[unit->texture].handle, true);
}
// Display
float transpar = (unit->fadeVal / unit->fadeMax);
if (shadowBrightness > 0.00f)
{
brushRect.setPosition(unit->shadowPos);
brushRect.setFillColor(color(0, 0, 0, shadowBrightness * transpar));
window.texHandle.draw(brushRect, window.matrixHandle);
}
brushRect.setPosition(unit->pos);
brushRect.setFillColor(color(255, 255, 255, 255 * transpar));
window.texHandle.draw(brushRect, window.matrixHandle);
visual.particlesPainted += 1;
}*/
}