# Code

**URL:** <https://forum.kirupa.com/t/code/63548>\
**Category:** Uncategorized\
**Created:** [September 7, 2004, 9:28pm UTC](https://forum.kirupa.com/t/code/63548 "2004-09-07T21:28:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![laforge](https://avatars.discourse-cdn.com/v4/letter/l/3da27b/32.png) [@laforge](https://forum.kirupa.com/u/laforge)\
**Post date:** [September 7, 2004, 9:28pm UTC](https://forum.kirupa.com/t/code/63548/1 "2004-09-07T21:28:37Z")

</div>

[left]Ok for the coding [http://www.flashkit.com/tutorials/Games/Building-David\_Do-611/index.php](http://www.flashkit.com/tutorials/Games/Building-David_Do-611/index.php) is there a way to make the enemies come from the top down? [/left]  
[left]I tried and it ended up coming from the bottom up. :h: Thanks for any help in advance[/left]

---

<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:** [September 7, 2004, 9:44pm UTC](https://forum.kirupa.com/t/code/63548/2 "2004-09-07T21:44:09Z")

</div>

[color=sienna]On this code:[/color] onClipEvent (load) { function reset(){ this.\_x=600; this.\_y=random(200)+100; enemySpeed=random(4)+1; } reset();}Give your this.\_x the random, and give the \_y a position abovethe screen. Go through the rest of your code and switchaccordingly[color=sienna]On this code:[/color]onClipEvent (enterFrame) { if (\_root.spaceship.scrollStart){ this.\_x-=enemySpeed+\_root.mainGround.groundSpeed; } else { this.\_x-=enemySpeed; } if (this.\_x\<-10) { reset(); }}change the \_x to \_y and make sure to change -= to +=.There will probably be a few more tweeks you will have to make, Ididn’t look through all the tutorial, but this should get you started

---

<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:** [September 7, 2004, 9:44pm UTC](https://forum.kirupa.com/t/code/63548/3 "2004-09-07T21:44:03Z")

</div>

[color=sienna]On this code:[/color] onClipEvent (load) { function reset(){ this.\_x=600; this.\_y=random(200)+100; enemySpeed=random(4)+1; } reset();}Give your this.\_x the random, and give the \_y a position abovethe screen. Go through the rest of your code and switchaccordingly[color=sienna]On this code:[/color]onClipEvent (enterFrame) { if (\_root.spaceship.scrollStart){ this.\_x-=enemySpeed+\_root.mainGround.groundSpeed; } else { this.\_x-=enemySpeed; } if (this.\_x\<-10) { reset(); }}change the \_x to \_y and make sure to change -= to +=.There will probably be a few more tweeks you will have to make, Ididn’t look through all the tutorial, but this should get you started

---

<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:** [September 7, 2004, 9:47pm UTC](https://forum.kirupa.com/t/code/63548/4 "2004-09-07T21:47:40Z")

</div>

[color=sienna]On this code:[/color]

onClipEvent (load) {  
function reset(){  
this.\_x=600;  
this.\_y=random(200)+100;  
enemySpeed=random(4)+1;  
}  
reset();  
}

Give your this.\_x the random, and give the \_y a position abovethe screen. Go through the rest of your code and switch accordingly  
[color=sienna][/color]  
[color=sienna]On this code:[/color]

onClipEvent (enterFrame) {  
if (\_root.spaceship.scrollStart)  
{  
this.\_x-=enemySpeed+\_root.mainGround.groundSpeed;  
}  
else {  
this.\_x-=enemySpeed;  
}  
if (this.\_x\<-10) {  
reset();  
}  
}

change the \_x to \_y and make sure to change -= to +=.

There will probably be a few more tweeks you will have to make, Ididn’t look through all the tutorial, but this should get you started
