Original Post
I'm doing a simple breakout clone and have completed it. I now want to add an extra element to it. I want the bricks to move from one side of the screen to the other. For example every brick on every row starts off moving right. When the last brick on the row (the first brick to hit the right border of the JFrame) hits the border it should bounce off it and start moving left. This should cause it to collide with the brick to the left of it causing that brick to bounce off it and move left hitting the next brick and so on. Basically the bricks switch direction when they hit either each other or the borders.
so far I can have an array of two bricks move from left to right bouncing off the sides but not each other. I've tried using intersect() but this isn't really working.
I can't think of a nice way of checking if element i in the array intersects with element [i - 1] or element [i + 1] as this causes Array out of bounds exceptions with the first and last element.
Wondering if anyone has any thoughts?
Many Thanks,
so far I can have an array of two bricks move from left to right bouncing off the sides but not each other. I've tried using intersect() but this isn't really working.
I can't think of a nice way of checking if element i in the array intersects with element [i - 1] or element [i + 1] as this causes Array out of bounds exceptions with the first and last element.
Wondering if anyone has any thoughts?
Many Thanks,