Space Invaders-type game: Keeping the enemies aligned with each other as they turn around?

Posted by CorundumGames on Game Development See other posts from Game Development or by CorundumGames
Published on 2012-07-09T02:16:59Z Indexed on 2012/07/09 3:23 UTC
Read the original article Hit count: 226

Filed under:
|
|
|

OK, so here's the lowdown of the problem I'm trying to solve.

I'm developing a game in PyGame that's a cross between Space Invaders and Columns. I'm trying to make the motion of the enemies similar to that of the aliens in Space Invaders; that is, they're all clustered in a grid, and if even one hits the side of the screen, the entire formation moves down and turns around. However, the motion of these aliens is continuous (as continuous as a monitor can be, anyway), not on a discrete grid like in the original.

The enemies are instances of an Enemy class, and in turn they're held by a 2D array in a enemysquadron module (which, if you don't use Python, is in this case essentially a singleton due to the way Python modules work).

Inside the Enemy class I have a class-scope velocity vector that is reversed every time an Enemy object touches the edge of the screen. This won't do, though, because as time goes on the enemies just become disorganized and jumbled (i.e. not in a grid as planned). I haven't implemented the Enemies going downward yet, so let's not worry about that right now.

Any tips?

© Game Development or respective owner

Related posts about ai

Related posts about sprites