#### Archived

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

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

## 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 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.

Later,
Viktor

##### 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 structureint xvect, y_vect;// vectors for the Invadersx_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:

http://www.nexicom.net/~guyjohnston/

Guy

##### Share on other sites
Thanks for the help, but I already fixed the problem and it''s working sweet....thanks again!

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
18

• 11
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×