First of all, my english isn’t that good, so please don’t tell me about it.
Now to my question.
I have a game where the player is a ball. And when the player hits a object, (a box) the ball, should bounce back 1 step. Its a wall.
Here is my problem.
Now its look like this:
if (Ball.hitTestObject(Wall))
{
Ball.x += 1;
}
But what it says it that if it hit on the left side it should bounce one to the right. But if i hit the box on the other side it ofcourse bounce 1 to the right agian, which makes it wrong.
I want to make it bounce Ball.x -= 1; if it’s hitting on the otherside. Which made my think of a system where its calculate the center of my box and then tells the boll like this.’
The box is 128 x 128.
Center is then 64.
If ball hits 0 ball bounce Ball.x -=1
If ball hits 128 ball bounce Ball.x +=1