Im just trying to finish off this space invaders game, but i ran into a problem.
Basically Ive got the aliens to move left-right on the top of the screen, but when they hit the left/right boundary they dont rebound as a block. They rebound separately… and then while doing that, they overlap eachother.
How can I make them rebound as a group rather than separately. Eg: The whole group to move from left to right.
http://users.tpg.com.au/egruber/invaders.JPG
public void alienArray()
{
alienCount = 0;
aliens = new ArrayList();
for (int i=0; i<4; i++)
{
for (int ii=0; ii<8; ii++)
{
Alien alienA = new Alien(10+ii*30,10+i*30);
alienA.setMovingRight( true );
aliens.add( alienA );
alienCount++;
}
}
…
…
private void checkPosition()
{
//Alien alienB = new Alien(10, 10);
for ( int ee=0; ee<32; ee++)
{
alien = (Alien)aliens.get(ee);
if ( alien.getXPos() == 600)
{
alien.setMovingRight(false);
alien.setMovingLeft(true);
}
if ( alien.getXPos() == 10)
{
alien.setMovingLeft(false);
alien.setMovingRight(true);
}
}
Any ideeas?
Thanks