views:

59

answers:

1

New Programmer here. Trying space invaders. I have a 2 dimensional array of objects stored in a one dimensional array (using modulo to determine rows and columns). Each object will return its boundaries in graphical space. I need to determine the boundaries (top, bottom, left, right) of the whole array for collision detection.

I feel like I'm missing something super simple. All my tests seem to only get the position of the last one. Also, some of the objects disappear, possibly changing the dimensions.

+1  A: 

The overall boundary box is

overall_top    = min(all of top)
overall_bottom = max(all of bottom)
overall_left   = min(all of left)
overall_right  = max(all of right)
KennyTM
Ha, I definitely realized this. My "Aha!" moment came when I realize I should set the top and left to the maximum value to start with and just test if it's smaller. (I was starting from the absolute min and trying to figure out how to get the new min, which doesn't really work).
quandrum