# Space Invader movement question

**URL:** <https://forum.kirupa.com/t/space-invader-movement-question/60435>\
**Category:** Uncategorized\
**Created:** [August 9, 2004, 9:16pm UTC](https://forum.kirupa.com/t/space-invader-movement-question/60435 "2004-08-09T21:16:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![H4T](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/h4t/32/329_2.png) [@H4T](https://forum.kirupa.com/u/H4T)\
**Post date:** [August 9, 2004, 9:16pm UTC](https://forum.kirupa.com/t/space-invader-movement-question/60435/1 "2004-08-09T21:16:23Z")

</div>

I’m trying to create a Space Invaders clone to learn more about game programming in Flash, and I’m kind of stuck on how to get them to move.

I have three different sprites, then 3 for loops duplicate them to make rows. Then, I want to make all the sprites move back and forth in unison, moving down a row every once in a while.

My prototype makes the sprites move left and right, checks for a collision with a wall, and if there is, reverse the direction and increment a variable. When that variable reaches say, 2, it shifts the Y position up a bit (moving the sprite(s) down).

But, the prototype is making each sprite move independantly, how can I make them ALL move in unison?

```auto
MovieClip.prototype.move = function() {
 	this.speed = 1;
 	
 	this.left = 5 + this._width/2;
 	this.right = 200 - this._width/2;
 	
 	this.onEnterFrame = function() {
 		this._x += this.speed;
 		
 		if(this._x < this.left) {
 			this.speed *= -1;
 			bounces++;
 		}
 		if(this._x > this.right) {
 			this.speed *= -1;
 			bounces++;
 		}
 		
 		if(bounces == 2) {
 			this._y += 5;
 			bounces = 0;
 		}
 	}
 }
 
 for(i=1; i<9; i++) {
 	_root["sprite3"+i].move();
 }

```

Any help appreciated.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 11, 2004, 12:24am UTC](https://forum.kirupa.com/t/space-invader-movement-question/60435/2 "2004-08-11T00:24:46Z")

</div>

Uhm…_bump_
