Untitled


SUBMITTED BY: Guest

DATE: Aug. 4, 2013, 3:18 p.m.

FORMAT: Text only

SIZE: 704 Bytes

HITS: 955

  1. onClipEvent (load) {
  2. this._x = random(550);
  3. //sets the horizontal position randomly
  4. this._y = random(-400);
  5. //sets the y position above the stage
  6. speed = random(5)+1;
  7. //sets the speed randomly
  8. }
  9. onClipEvent (enterFrame) {
  10. this._y += speed;
  11. //moves the enemy downwards
  12. if (this.hitTest(_root.head)) {
  13. //if the enemy hits the player
  14. _root.gotoAndStop(2);
  15. //goto the second frame, which will be a gameover screen
  16. }
  17. if (this._y>=310) {
  18. //if the player reaches 10 pixels below the stage
  19. this._x = random(550);
  20. //randomly set the x, y and speed again.
  21. this._y = random(-400);
  22. speed = random(5)+1;
  23. }
  24. }

comments powered by Disqus