Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Space Invaders are overlapping!!

This topic is 6070 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Help! I''m developing a Space Invaders clone and have one problem. When the line of aliens hits the left edge of the screen, they move down a line, but the left most alien starts to get closer to the one next to it. They eventually overlap. This doesn''t do this on the right side of the screen, only the left. I have checked all my speed and y-increment variables and they are all the same. Any suggestions? Thanks.

Share this post

Link to post
Share on other sites
Are you using floating point variables? Maybe for velocity vector or your x and y coordinates? If so, make sure the rounding is correct... If you can''t find the problem I suggest you paste the relevant code where you move the objects.


Share this post

Link to post
Share on other sites

Just finished a Direct X group project Space Invader clone.

What I did was move the Space Invaders in blocks. So I had a loop that move them left or right. If one of the invaders got to the edge of the screen, I threw up a flag so that it engaged another loop afterwards that made them all move downward at once.

It went something like this. I tried to summate/cut fat.
It''s the general idea.

// Globals or in Invader structure

int xvect, y_vect;// vectors for the Invaders

x_vect = 4;
y_vect = 12;


void Move_Invaders()
BOOL bx_rev = FALSE; // for change in x direction

for ( int loop = 0 ; loop < MAX_ALIENS ; loop++ )
{ // add to x_pos

Alien [ loop ].xpos += x_vect;
// Hit a side ? Then change direction and move down

if ( ( Alien [ loop ].x_pos > 760 ) ||
( Alien [ loop ].x_pos < 0 ) )
bx_rev = TRUE; // flag indicating x reversal

}// end for( int loop ...

// flag set to reverse their direction, then negate x_vect

if ( bx_rev == TRUE )
{ // change their x direction

x_vect = - x_vect;

// move them all down

for ( int loop_2 = 0 ; loop_2 < MAX_ALIENS ; loop_2++ )
Alien [ loop_2 ].y_pos += y_vect;
}// end if bx_rev

}// end Move_Invaders

The Space Invader Game that our group made is a little buggy. It uses Direct X. Nothing fancy, just the basic mechanics.

You can pick up a copy if you like at my web site:



Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!