//Check intersection with ball and blocks
for(int i=0; i<blocks.size(); i++) {
if(blocks.get(i) instanceof BasicBlock) {
BasicBlock b = (BasicBlock) blocks.get(i);
if(checkBoxPos(b)) {
score += 10;
blocks.remove(i);
b.setDestroyed();
b.setVisible(false);
}
} else if(blocks.get(i) instanceof SecondBlock){
SecondBlock b = (SecondBlock) blocks.get(i);
if(checkBoxPos(b)) {
b.timesHit++;
b.setImage(basicBlockImg);
if(b.timesHit == 2) {
score += 15;
blocks.remove(i);
b.setDestroyed();
b.setVisible(false);
} else score += 5;
}
} else if(blocks.get(i) instanceof ThirdBlock) {
ThirdBlock b = (ThirdBlock) blocks.get(i);
if(checkBoxPos(b)) {
b.timesHit++;
if(b.timesHit == 1){
b.setImage(secondBlockImg);
score += 5;
} else if(b.timesHit == 2) {
b.setImage(basicBlockImg);
score += 5;
} else if(b.timesHit == 3) {
score += 20;
b.setDestroyed();
b.setVisible(false);
blocks.remove(i);
}
}
} else if(blocks.get(i) instanceof BonusLifeBlock) {
BonusLifeBlock b = (BonusLifeBlock) blocks.get(i);
int blockX = (int) b.getRect().getMinX();
int blockY = (int) b.getRect().getMaxY();
if(checkBoxPos(b)) {
b.timesHit++;
b.setImage(bonusLifeBlockDamImg);
if(b.timesHit == 2) {
//lives++;
blocks.remove(i);
b.setDestroyed();
b.setVisible(false);
drops.add(new BonusLifeItem(bonusLifeItemImg, blockX, blockY));
} else score += 10;
}
}
}