Ok, so…
I made a new program. Its basically a window with a buffered graphics content.
It has 2 squares, one stays in the center, one moves around the screen. I made collision detection for the moving square like
if (square2y == squareY+squareH){
if (square2x > squareX){
if (square2x< squareX+squareW){
dy= -dy;
}
}
}
if (square2x == squareX+squareW){
if (square2y > squareY){
if (square2y < squareY+squareH){
dx= -dx;
}
}
}
etc…
Worked great, also found out 1 probable cause of my other program not working, I was using if more than, rather than if equals to.
then I added
me.setBounds(squareX+10, squareY+10, squareW+10, squareH+10);
him.setBounds(square2x+10, square2y+10, square2W+10, square2H+10);
and and if statement to my first collision detection to see if collidesWith method works
and it does, another thing i found out is that i had to make the bounds slightly larger than my squares or else my first collision detection wouldn’t work out right.
I think where I’m having problems mainly with my original program is after collidesWith is called,
in my collidedWith function, I’m not getting the right data, like collided with brick, I’m not getting the right values for the bricks x,y,width, height. If you look at my earlier post it shows how I tried to get this data eg. other.getY() might be returning something else’s X coordinate.
I’m sure this is down to the way my program is set out.
But any thoughts on this would be great
And is this normal for a beginner to have problems like this? I know that might not be a simple yes or no answer.
Thanks again