And some code if it helps....
spacebar event
if (event.type == sf::Event::KeyPressed)
{
if (event.key.code == sf::Keyboard::Space)
{
if(allowBomb==1)
{
Bomb bomb(-32,-32,96,96,player1.getPosition().x,player1.getPosition().y); // -1 and 34 so collision rect overlaps/collides with vBlocks next to bomb
bomb.setTextureRect(sf::IntRect(0,0,32,32));
bomb.setTexture(bombTexture);
vBombs.push_back(bomb);
fuseSound.play();
allowBomb=0;
}
}
}
this is the main game loop where the bomb is displayed (most of this is irrelevant to this but for the bomb parts)...I just thought it odd the blocks are displayed in a loop too
window.draw(vBlocks[i])
and they dont appear to be rough round the edges like the bomb is?
for (unsigned int i = 0; i != vBlocks.size(); i++) {
if(player1.isCollidingWith(vBlocks[i])){
player1.collide(vBlocks[i]);
}
for (itBomb = vBombs.begin(); itBomb != vBombs.end(); itBomb++)
{
if(itBomb->getBombTimer()>1){
if(itBomb->isCollidingWith(vBlocks[i])){
//check if indesctructable
if(vBlocks[i].isDestructable!=true)
{
//otherwise remove block
vBlocks.erase(vBlocks.begin()+i);
}
//check if player in blast
if(itBomb->isCollidingWith(player1))
{
cout<<"player 1 is dead";
}
}
if(itBomb->getExploded()==false)
{
boomSound.play();
itBomb->setExploded();
allowBomb=1; // allow the laying of another bomb now
}
if(itBomb->getBombTimer()>2)
{
itBomb=vBombs.erase(itBomb);
break;
}
}else{
window.draw(*itBomb);
}
}
window.draw(vBlocks[i]);
}
window.draw(player1);
window.draw(sprite); // this is a test bomb...remove!
window.display();