Quote:
Originally Posted by r035198x
Well, I'm not going to download those files and I know a few others who wont as well. It's better if you tell us what characteristics you want your wall to have. The bouncing can be controlled by tracking the position of the ball on the canvas (or whatever it is you are using) and changing the direction of the ball as soon as it enters certain coordinates. You can even make the wall invisible.
It is a little hard to describe without actually seeing it. Well, basically I have two boxes:
- g.drawRect(10,0,950,500);
-
g.drawRect(350,170,200,150);
One box inside the other, right now the ball will bounce inside the first box, but the part I am having trouble with is making the inside box also make the ball bounce when hit.
For the first box I just took the x or y and then changed direction example:
-
if (x > 910) /** bounces back left when x = 910 */
-
{dir = dir - 2;}
But, because the other box is on the inside it will not work. I need to find out how to add walls that the ball will bounce off of. Preferably something that will not require at lot of check for the ball going into a certain point. But, anything that works would be great.