What actually happens: The ball replaceswill sometimes set to the ballwrong cell, and my "dropping" code will detect it should stick toas a loner and drop it off the stage.
//Counstruct our bounding rectangle for use
var nX = currentBall.x + ballvX * gameTime;
var nY = currentBall.y - ballvY * gameTime;
var movingRect = new BoundingRectangle(nX, nY, 32, 32);
var able = false;
//Iterate over the cells and draw our bubbles
for (var x = 0; x < 8; x++) {
for (var y = 0; y < 12; y++) {
//Get the bubble at this layout
var bubble = bubbleLayout[x][y];
var rowHeight = 27;
//If this slot isn't empty, draw
if (bubble != null) {
var bx = 0, by = 0;
if (y % 2 == 0) {
bx = x * 32 + 270;
by = y * rowHeight32 + 45;
} else {
bx = x * 32 + 270 + 16;
by = y * rowHeight32 + 45;
}
//Check
var targetBox = new BoundingRectangle(bx, by, 32, 32);
if (targetBox.intersects(movingRect)) {
able = true;
}
}
}
}
cellXcellY = Math.round((nXcurrentBall.y - 27045) / 32);
if (cellY % 2 == 0)
cellYcellX = Math.round((nYcurrentBall.x - 45270) / 32);
else
var pointsThisFramecellX = 0;
//TODO: This is a new collision mechanism, should hopefully solve a bug..Math.
var isEven = cellY % 2 == 0;
if round(true) {
//Check the bubble layout
if (cellYcurrentBall.x ==- 0270 ||- able16) {
//TODO: Finish game losing conditions
if (cellY == 9) {
winGame(32);
// cellY++;
}
//Safety check
//if(cellX == rCellX && cellY == rCellY && cellY > 0)
// return;
//Assign the grid
bubbleLayout[cellX][cellY] = currentBall;
ballvX = 0;
ballvY = 0;