function blocksLogic(){
if(gameRunning == 0){
var blocks = new Array(7);
for(var i=0; i <7; i++){
blocks[i] = new Array(7);
}
for(var x=0; x < 7; x++){
for(var y=0; y < 7; y++){
blocks[x][y] = false;
console.log(blocks[x][y]);
}
}
}
console.log("gamerunning function ran");
// COLLISION!!!!!!!
for(var brickX = 0; x < 7; x++){
console.log("for x has been run!");
for( var brickY = 0; y < 7; y++){
console.log("for y has been run!");
var tempBrickX = brickX * 105 + 34;
var tempBrickY = brickY * 25 - 10;
//top collision
if(ballY >= tempBrickX && ballX >= tempBrickX && ballX <= tempBrickX + BRICK_WIDTH){
console.log("The top of this block has been hit!");
ballSpeedX = -ballSpeedX;
ballSpeedY = -ballSpeedY;
}
//bottom collision
if(ballY <= tempBrickY + BRICK_HEIGHT && ballX >= tempBrickX && ballX >= tempBrickX){
console.log("The bottom of this brick has been hit!");
ballSpeedX = -ballSpeedX;
ballSpeedY = -ballSpeedY;
}
}
}
The function blocksLogic is not running the code below the comment "//COLLISION!" its probably something really simple but im just starting to get into coding with javascript(thats why my code formatting sucks) i added alot of debugging console.logs to see what was running and what wasnt.