I can tell you my logic but I can't give you the code you just tell me if this sounds logical or not:

first you create a formation a formation is an array that contains the coordinates of up to n aliens (lets say 3 in this example.

So for any Formation you have 3 aliens a1, a2 and a3, where you would have the coordinates for x and y defined as integers as you already have.

The change is that in your edge collision detection routine you have to check for the impact of only the alien closest to that side of the screen

lets use a simple space invaders formation where they move side by side (after this we can go into the galaga type formation i think you're looking for)

for this example lets say that you have a screen 100 pix wide and every alien is 1 pix wide

the space invaders formation algorithm goes like this:

Starting from the top left corner going back and fort and descending every time you hit a wall

but in order to move in formation they all detect the collision depending on the alien closest to the wall.

so our formation is A1 - A2 - A3 (aliens)

at the begining the coordinates of

a1 are a1.x=0 and a1.y =0 ,

for a2 a2.x=a1.x+(width of alien) + (width of space in formation) and a2.y =0,

for alien 3 the coordinates are

a3.x=a2.x+(width of alien) + (width of space in formation) and a2.y =0,

So you move them by increasing only a1.x the calculation routine takes care of the rest

Movement routine

Movement Direction has two variables (x) and (y)

so MD.x=1 md.y=0

every cycle then

a1.x=a1.x+md.x

a1.y=a1.y+md.y

UNTIL

the highest living alien in this case a3 if it has not been killed hits the edge of the screen

in this case

if a3.x= 100 then a1.x=a1.x-1 a1.y=a1.y+1 and md.x=-1 md.y=0

(you cange the direction of movement, since we're in space invaders they descend one level and start moving backwards)

tell me what you think

first you create a formation a formation is an array that contains the coordinates of up to n aliens (lets say 3 in this example.

So for any Formation you have 3 aliens a1, a2 and a3, where you would have the coordinates for x and y defined as integers as you already have.

The change is that in your edge collision detection routine you have to check for the impact of only the alien closest to that side of the screen

lets use a simple space invaders formation where they move side by side (after this we can go into the galaga type formation i think you're looking for)

for this example lets say that you have a screen 100 pix wide and every alien is 1 pix wide

the space invaders formation algorithm goes like this:

Starting from the top left corner going back and fort and descending every time you hit a wall

but in order to move in formation they all detect the collision depending on the alien closest to the wall.

so our formation is A1 - A2 - A3 (aliens)

at the begining the coordinates of

a1 are a1.x=0 and a1.y =0 ,

for a2 a2.x=a1.x+(width of alien) + (width of space in formation) and a2.y =0,

for alien 3 the coordinates are

a3.x=a2.x+(width of alien) + (width of space in formation) and a2.y =0,

So you move them by increasing only a1.x the calculation routine takes care of the rest

Movement routine

Movement Direction has two variables (x) and (y)

so MD.x=1 md.y=0

every cycle then

a1.x=a1.x+md.x

a1.y=a1.y+md.y

UNTIL

the highest living alien in this case a3 if it has not been killed hits the edge of the screen

in this case

if a3.x= 100 then a1.x=a1.x-1 a1.y=a1.y+1 and md.x=-1 md.y=0

(you cange the direction of movement, since we're in space invaders they descend one level and start moving backwards)

tell me what you think