Very nice game but there is one bug I think: Sometimes when the ball hits a wall it just goes along the wall and dosen't get away there. I think you could do this with a loop in your method which tells the ball to turn when he hits the wall, because the problem probably is that the ball hits the wall again and again and again.
if you use:
while (getY() < 10) { //or another number. I don't know the real number from your game.
move(1); //or if this doesn't work use setLocation(getX(), getY()+1);
}
And maybe you could include a better artificial intelligence
This one only follows the ball. And if I hit the ball with a steep angle it doesn't get the ball most time.
But all in all a very nice game.
The easy fix for the wall-hugging problem is using a double condition as follows:
if (ySpeed > 0 && getX() > getWorld().getHeight() - 11) ySpeed = -ySpeed;
if (ySpeed < 0 && getX() <= 11) ySpeed = -ySpeed;
Of course, I chose 11 as an arbitrary number and you should adjust it to the appropriate value for the size of your ball. The two statements can be combined into one larger 'if' by wrapping each set of conditions in parenthesis and ORing them together.
if ((ySpeed > 0 && getX() > getWorld().getHeight() - 11) || (ySpeed < 0 && getX() <= 11)) ySpeed = -ySpeed;
To make the ball move, I used the Actor method move(int), but I get your point. to mirror an objects direction I'll just change the angle using the methods i already created.
A new version of this scenario was uploaded on Wed Sep 19 13:45:56 UTC 2012
Fixed color bug
2012/8/12
2012/9/16
2012/9/18
2012/9/18
2012/9/19