Originally Posted by
burntcasadilla
alright im back at square one and im completely confused. ill take this step by step:
1. created this method within the ball class in order to create a method that returns the dimensions of the ball
public Rectangle getBallBounds()
{
return new Rectangle(this.x, this.y, 20, 20);
}
Looks good to me. I think the method could probably be static. Each ball would use the same process to return it's own bounds.
Originally Posted by
burntcasadilla
2. In the updateGame() method, i want to run the getBallBounds() method everytime a new ball is created, but im not sure if this is the right way to do this
Sounds ok to me, without seeing the rest of the code.
Originally Posted by
burntcasadilla
3. Another alternative would be creating a for loop like you suggested and storing the rectangles in an array list, but you said not to do this for some reason
1)Calling a method for the bounds of a ball when you need it, sounds like a good way to handle it. Allowing the ball handle it's own data rather than storing the same thing twice.
2)The loop is a bad idea because the ball's bounding box belongs to the ball, and should be accessed through the class methods. Storing the same thing a new ArrayList is one more ArrayList than you need to handle with the program.