Hi everyone!
I have a problem concerning a game me and a couple of other friends are creating.
The game is like pong, but its only one pad, one ball and blocks the ball is supposed to destroy on impact.
We are only able to make the blocks dissapear temporarily while the ball is INSIDE the block, when it leaves the block comes back again.
The code we are using for this looks like this:
void blocks() {
blocks = loadImage("blocks.jpeg");
for(int a=0;a<arrLenY;a++) {
for(int b=0;b<arrLenX;b++) {
if(ballX+dia >= xposBlock[b] && ballX-dia <= xposBlock[b]+blockWid && ballY+dia >= yposBlock[a] && ballY-dia <= yposBlock[a]+blockHei) {
//Rectangel should be GONE!
} else {
image(blocks,xposBlock[b],yposBlock[a],blockWid,blockHei);
//rectangel is there!
}
}
}
}
Some Variables:
xposBlock[b] = array with xblock-positions, same with yposBlock[a]
blocks = image filename
dia = diameter of the ball
ellipseMode = CENTER.
If you are interested in helping us but need more information regarding the program/the full code, please tell, Im pretty unexperienced asking question about programming-related stuff like this so please have patience:) We REALLY need help with this one!
Allright, thx alot
// Haldur