Hey guys I was hoping some of you here may know how to help me with this problem I'm having where I have created picture boxes that are aliens in a game of space invaders and they move from left to right down once then right to left just like traditional space invaders.
My problem is that when they move, they are moving in a snake formation rather than as a whole unit, its like they just run in a big zig zag shape overlapping each other, I have been trying to figure out how to move them all down at once. I have my code for the move method at the bottom of this post, if anyone can give me any advice or tips I would greatly appreciate that!!!

Thanks a lot!!!

public override void Move()
        {
           if ((position.X < boundary.Width -50) && (counter == 0))
            {
                position.X += 1;
                picture.Location = position;
            }
            else if ((position.X == boundary.Width - 50) && (counter == 0))
            {
                position.Y = position.Y + 50;
                counter++;
                picture.Location = position;
            } else if ((position.X > 0) && (counter == 1))
            {
                position.X -= 1;
                picture.Location = position;
            }
            else if ((position.X == 0) && (counter == 1))
            {
                position.Y = position.Y + 50;
                counter--;
                picture.Location = position;
            }

            }
            // aliens move from right to left then moving down and to the right etc....
        }

If each of your aliens is in a separate picturebox then they will never move at the same time. Each object will be refreshed in turn and this could be the reason why it looks like they overlap.
Consider painting them in the form paint event handler instead of in a picturebox.

If each of your aliens is in a separate picturebox then they will never move at the same time.
Each object will be refreshed in turn and this could be the reason why it looks like they overlap.
Consider painting them in the form paint event handler instead of in a picturebox.
This way you know they are all drawn at the same time.

If each of your aliens is in a separate picturebox then they will never move at the same time.
Each object will be refreshed in turn and this could be the reason why it looks like they overlap.
Consider painting them in the form paint event handler instead of in a picturebox.
This way you know they are all drawn at the same time.

Thanks for the advice, if I put them in the form paint event handler, can I still remove an alien if they are hit by the bullet picturebox? I dont want to change my programme drastically as I am kind of new to programming and don't really know how to change from picture box's to the form paint event handler. I will definitely look into this though.

Many thanks

I'd try turning on double buffering for the form, and using SuspendLayout/ResumeLayout on the pictureboxes (suspend them all before doing the move, resume them after).

You could also try suspending and resuming layout on the form itself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.