home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Puzzle / neko_juppiki.swf / scripts / DefineSprite_42 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-03-20  |  2.6 KB  |  134 lines

  1. function init()
  2. {
  3.    this.WALL_LEFT = 10;
  4.    this.WALL_RIGHT = 630;
  5.    this.dx = 2;
  6.    this.dy = 0;
  7.    this.px = this._x;
  8.    this.py = this._y;
  9.    this.stat = "standby";
  10.    _parent.neko_mc_list.push(this);
  11.    this.floor_num = 0;
  12. }
  13. function main()
  14. {
  15.    switch(this.stat)
  16.    {
  17.       case "run":
  18.          this.run();
  19.          break;
  20.       case "fall":
  21.          this.fall();
  22.          break;
  23.       case "death":
  24.          this.death();
  25.    }
  26.    this._x = this.px;
  27.    this._y = this.py;
  28. }
  29. function entryStartRun()
  30. {
  31.    this.stat = "run";
  32. }
  33. function entryFall()
  34. {
  35.    if(this.stat == "fall")
  36.    {
  37.       return undefined;
  38.    }
  39.    this.mc_g.gotoAndStop("fall");
  40.    this.floor_num = this.floor_num + 1;
  41.    this.stat = "fall";
  42.    this.ground_y = 60 + this.floor_num * 80;
  43. }
  44. function entryDeath()
  45. {
  46.    if(this.stat == "death")
  47.    {
  48.       return undefined;
  49.    }
  50.    this.stat = "death";
  51.    this.mc_g.gotoAndStop("death");
  52.    if(_root.game_mode == 1)
  53.    {
  54.       _root.neko = _root.neko - 1;
  55.       _parent.neko_end_cnt = _parent.neko_end_cnt + 1;
  56.       if(_root.neko == 0)
  57.       {
  58.          _root.gotoAndPlay("gameover");
  59.       }
  60.    }
  61.    else if(_root.stat == "main")
  62.    {
  63.       _root.neko = _root.neko - 1;
  64.       if(_root.neko == 0)
  65.       {
  66.          _root.gotoAndPlay("gameover");
  67.       }
  68.       else
  69.       {
  70.          _root.gotoAndPlay("miss");
  71.       }
  72.    }
  73. }
  74. function run()
  75. {
  76.    this.px += this.dx;
  77.    this.py += this.dy;
  78.    if(this.px <= this.WALL_LEFT)
  79.    {
  80.       this.px = this.WALL_LEFT;
  81.       this.dx = - this.dx;
  82.    }
  83.    if(this.px >= this.WALL_RIGHT)
  84.    {
  85.       this.px = this.WALL_RIGHT;
  86.       this.dx = - this.dx;
  87.    }
  88.    if(this.dx > 0)
  89.    {
  90.       this._xscale = 100;
  91.    }
  92.    else
  93.    {
  94.       this._xscale = -100;
  95.    }
  96.    if(this.mc_hit.hitTest(_parent.mc_home.mc_hit))
  97.    {
  98.       this.stat = "goal";
  99.       this.mc_g.gotoAndStop("goal");
  100.       _parent.neko_end_cnt = _parent.neko_end_cnt + 1;
  101.       _parent.neko_goal_cnt = _parent.neko_goal_cnt + 1;
  102.       _parent.mc_home.entryMark(_parent.neko_goal_cnt);
  103.       if(_root.game_mode == 1)
  104.       {
  105.          if(_parent.neko_end_cnt == 10)
  106.          {
  107.             _root.gotoAndPlay("stageclear");
  108.          }
  109.       }
  110.       else if(_parent.neko_goal_cnt == 10)
  111.       {
  112.          _root.gotoAndPlay("stageclear");
  113.       }
  114.    }
  115. }
  116. function fall()
  117. {
  118.    this.dy = this.dy + 1;
  119.    this.px += this.dx / 2;
  120.    this.py += this.dy;
  121.    if(this.py >= this.ground_y)
  122.    {
  123.       this.py = this.ground_y;
  124.       this.dy = 0;
  125.       this.stat = "run";
  126.       this.mc_g.gotoAndPlay("walk");
  127.    }
  128. }
  129. function death()
  130. {
  131.    this.mc_g.gotoAndStop("death");
  132. }
  133. this.init();
  134.