本文整理汇总了C++中screen::setArrayElement方法的典型用法代码示例。如果您正苦于以下问题:C++ screen::setArrayElement方法的具体用法?C++ screen::setArrayElement怎么用?C++ screen::setArrayElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类screen
的用法示例。
在下文中一共展示了screen::setArrayElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: damage
//-----------------------------------
void bomb::damage(sf::RenderWindow& window, sf::Sprite& sprFire)
{
if (scrn.getArrayElement(calculateIndex(b),calculateIndex(l)+1) != 4)
{
for (int i=0; i <= dst; ++i)
{
if (scrn.getArrayElement(calculateIndex(b), calculateIndex(l)+i) == 2 )
{
if (first)
{
bricks.remove(brick(l+i*step, r+(i*step), b, t, scrn));
scrn.setArrayElement(0, calculateIndex(b), calculateIndex(l)+i);
}
break;
}
if (scrn.getArrayElement(calculateIndex(b), calculateIndex(l)+i) == 3)
{
enemies.remove( enemy ( l + i*step, r + i*step, b, t, scrn) );
scrn.setArrayElement(0, calculateIndex(b), calculateIndex(l) + i);
}
sprFire.setPosition(sf::Vector2f(l + i*step, b));
window.draw(sprFire);
}
}
if (scrn.getArrayElement(calculateIndex(b), calculateIndex(l)-1) != 4)
{
for (int i=0; i <= dst; ++i)
{
if (scrn.getArrayElement(calculateIndex(b), calculateIndex(l) - i) == 2 && first)
{
if(first)
{
bricks.remove(brick( l - i*step, r - i*step, b, t, scrn));
scrn.setArrayElement(0, calculateIndex(b), calculateIndex(l) - i);
}
break;
}
if (scrn.getArrayElement(calculateIndex(b), calculateIndex(l) - i - 1) == 3 )
{
enemies.remove( enemy (l-i*step, r-i*step, b, t, scrn) );
scrn.setArrayElement(0, calculateIndex(b), calculateIndex(l) - i - 1);
}
sprFire.setPosition(sf::Vector2f(l- i*step, b));
window.draw(sprFire);
}
}
if (scrn.getArrayElement(calculateIndex(b)+1, calculateIndex(l)) != 4 )
{
for (int i=0; i <= dst; ++i)
{
if (scrn.getArrayElement(calculateIndex(b)+i, calculateIndex(l)) == 2 && first)
{
if(first)
{
bricks.remove(brick(l, r, b+i*step, t+i*step, scrn));
scrn.setArrayElement(0, calculateIndex(b)+i, calculateIndex(l));
}
break;
}
if (scrn.getArrayElement(calculateIndex(b)+i, calculateIndex(l)) == 3)
{
enemies.remove( enemy (l, r, b+i*step, t+i*step, scrn) );
scrn.setArrayElement(0, calculateIndex(b)+i, calculateIndex(l));
}
sprFire.setPosition(sf::Vector2f(l, b+ i*step));
window.draw(sprFire);
}
}
if (scrn.getArrayElement(calculateIndex(b)-1, calculateIndex(l)) != 4)
{
for (int i = 0; i <= dst; i++)
{
if (scrn.getArrayElement(calculateIndex(b)-i, calculateIndex(l)) == 2)
{
if (first)
{
bricks.remove(brick (l, r, b-i*step, t-i*step, scrn));
scrn.setArrayElement(0, calculateIndex(b)-i, calculateIndex(l));
}
break;
}
if (scrn.getArrayElement(calculateIndex(b)-i, calculateIndex(l)) == 3)
{
enemies.remove (enemy (l, r, b-i*step, t-i*step, scrn));
scrn.setArrayElement (0, calculateIndex(b)-i, calculateIndex(l));
}
sprFire.setPosition(sf::Vector2f(l , b - i*step));
window.draw(sprFire);
}
}
if (first)
{
first = false;
}
return;
}