So Ive been having some issues with collision. One has led me in the right direction to getting my paddle and ball bouncing off properly. I created at function that should delete the blocks when making contact with the ball. The score tallies up, but the blocks wont disapear. Basically, it appears the dbDeleteSprite() doesnt work. I have the right ID connected to the dbDeleteSprite() function so that it will delete the block sprites. Another little problem is that all the blocks respond to the score increment except the first cell. Here is my function...
[void pBlockHit (void)
{
int iBallX = dbSpriteX (2);
int iBallY = dbSpriteY (2);
int iBlocksSprite = 3;
// check if the ball touched the blocks
for (int iY = 0 ; iY < 6 ; iY++)
{
for (int iX = 0; iX < 6 ; iX++)
{
iBlocksSprite++;
if (g_bBlocksAlive[iX][iY] == false)
continue;
int iBlocksX = dbSpriteX (iBlocksSprite);
int iBlocksY = dbSpriteY (iBlocksSprite);
// have we scored a hit?
if ((iBallX > iBlocksX && iBallX < iBlocksX + dbSpriteWidth(iBlocksSprite)) || (iBallX > iBlocksX && iBallX < iBlocksX + dbSpriteWidth(iBlocksSprite)))
{
if ((iBallY > iBlocksY && iBallY < iBlocksY + dbSpriteHeight(iBlocksSprite)) || (iBallY > iBlocksY && iBallY < iBlocksY + dbSpriteHeight(iBlocksSprite)))
{
//// yes! we have hit an enemy, lets increase the score and blow that enemy up
//dbPlaySound ( 3 );
// delete the sprite
dbDeleteSprite (iBlocksSprite);
iBallY -= iBallSpeedY;
iBallSpeedY = -1;
g_bBlocksAlive[iX][iY] = false;
// Update score
g_iPlayerScore += 100;
playerUpdateScore();
return;
}
}
}
}
}]
"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo