home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / catitens.swf / scripts / frame_4 / DoAction_2.as next >
Encoding:
Text File  |  2007-09-27  |  6.9 KB  |  299 lines

  1. stop();
  2. stopAllSounds();
  3. _root.level = 1;
  4. _root.score = 0;
  5. _root.enemy_num = 1;
  6. _root.item_num = 8;
  7. _root.count_num = 0;
  8. _root.menu_mc.life.gotoAndStop(1);
  9. _root.man2.gotoAndStop(7);
  10. _root.time_num = 0.05;
  11. _root.hurting = false;
  12. _root.sound_ok = true;
  13. FNstart = function()
  14. {
  15.    _root.game_start = true;
  16. };
  17. FNchogi = function(mc)
  18. {
  19.    mc.fall = 0;
  20.    mc.downing = false;
  21.    mc.speedX = 6;
  22.    mc.speedY = 5;
  23.    mc.stand = true;
  24.    mc.gotoAndStop(1);
  25.    mc.posY = _root.bg._y;
  26.    mc.posY1 = _root.back._y;
  27. };
  28. FNchogi(_root.man);
  29. FNchogi2 = function(mc)
  30. {
  31.    mc._visible = false;
  32.    _root.man_alpha.gotoAndStop(1);
  33.    _root.man2._visible = false;
  34.    mc._xscale = 130;
  35.    mc.gotoAndStop(1);
  36. };
  37. FNchogi3 = function(mc)
  38. {
  39.    mc._visible = true;
  40.    _root.man2._visible = true;
  41.    mc._xscale = 130;
  42.    mc.gotoAndStop(1);
  43. };
  44. FNscore = function(s, num)
  45. {
  46.    var _loc2_ = 1;
  47.    while(_loc2_ <= 5)
  48.    {
  49.       this.menu_mc[s + _loc2_].gotoAndStop(Math.floor(num / Math.pow(10,_loc2_ - 1)) % 10 + 1);
  50.       _loc2_ = _loc2_ + 1;
  51.    }
  52. };
  53. FNscore("l",_root.level);
  54. FNscore("s",_root.score);
  55. FNitem = function()
  56. {
  57.    var _loc2_ = 1;
  58.    while(_loc2_ <= _root.item_num)
  59.    {
  60.       _root.back["o" + _loc2_].gotoAndStop(random(6) + 2);
  61.       _loc2_ = _loc2_ + 1;
  62.    }
  63. };
  64. FNitem();
  65. FNright = function(mc, speed)
  66. {
  67.    if(mc.stand)
  68.    {
  69.       mc.gotoAndStop("walking");
  70.    }
  71.    else
  72.    {
  73.       mc.gotoAndStop("fly_walking");
  74.    }
  75.    if(_root.bg2.hitTest(mc._x + speed,mc._y,true) == false && _root.bg.hit.hitTest(mc._x + speed + 20,mc._y,true) == false)
  76.    {
  77.       mc._x += speed;
  78.    }
  79. };
  80. FNleft = function(mc, speed)
  81. {
  82.    if(mc.stand)
  83.    {
  84.       mc.gotoAndStop("walking");
  85.    }
  86.    else
  87.    {
  88.       mc.gotoAndStop("fly_walking");
  89.    }
  90.    if(_root.bg2.hitTest(mc._x - speed,mc._y,true) == false && _root.bg.hit.hitTest(mc._x - speed - 20,mc._y,true) == false)
  91.    {
  92.       mc._x -= speed;
  93.    }
  94. };
  95. FNup = function(mc, speed, mc1)
  96. {
  97.    if(mc.stand)
  98.    {
  99.       mc.stand = false;
  100.       mc.downing = false;
  101.       mc.gotoAndStop("fly");
  102.    }
  103.    mc.fall = 0;
  104.    if(_root.bg.hit.hitTest(mc._x,mc._y - speed,true) == false)
  105.    {
  106.       if(mc._y > 250)
  107.       {
  108.          mc._y -= speed;
  109.       }
  110.       else if(_root.bg._y > 950)
  111.       {
  112.          if(mc._y > 60)
  113.          {
  114.             mc._y -= speed;
  115.          }
  116.       }
  117.       else
  118.       {
  119.          _root.bg._y += speed;
  120.          _root.back._y += speed;
  121.       }
  122.    }
  123.    if(mc.mc_in.bubble._currentframe < 11)
  124.    {
  125.       mc.mc_in.bubble.play();
  126.       mc1.mc_in.bubble.play();
  127.    }
  128.    else if(mc.mc_in.bubble._currentframe > 11)
  129.    {
  130.       mc.mc_in.bubble.gotoAndPlay(21 - (mc.mc_in.bubble._currentframe - 1));
  131.       mc1.mc_in.bubble.gotoAndPlay(21 - (mc1.mc_in.bubble._currentframe - 1));
  132.    }
  133. };
  134. FNdown = function(mc, speed, mc1)
  135. {
  136.    if(_root.bg.hit.hitTest(mc._x,mc._y + mc.fall + speed,true))
  137.    {
  138.       mc.stand = true;
  139.       mc.downing = false;
  140.       mc.fall = 0;
  141.    }
  142.    else
  143.    {
  144.       mc.downing = true;
  145.       if(mc._y > 230 && mc._y < 250)
  146.       {
  147.          if(_root.back._y > mc.posY1)
  148.          {
  149.             _root.bg._y -= mc.fall;
  150.             _root.bg._y -= speed;
  151.             _root.back._y -= mc.fall;
  152.             _root.back._y -= speed;
  153.          }
  154.          else
  155.          {
  156.             _root.back._y = mc.posY1;
  157.             _root.bg._y = mc.posY;
  158.             mc._y += mc.fall;
  159.             mc._y += speed;
  160.          }
  161.       }
  162.       else if(mc._y < 230)
  163.       {
  164.          mc._y += mc.fall;
  165.          mc._y += speed;
  166.       }
  167.       else
  168.       {
  169.          mc._y += mc.fall;
  170.          mc._y += speed;
  171.       }
  172.       if(mc.fall == 0)
  173.       {
  174.          mc.mc_in.bubble.gotoAndPlay(11 + (11 - mc.mc_in.bubble._currentframe));
  175.          mc1.mc_in.bubble.gotoAndPlay(11 + (11 - mc1.mc_in.bubble._currentframe));
  176.       }
  177.       mc.fall += 0.5;
  178.    }
  179. };
  180. FNgoal = function(mc, mc1)
  181. {
  182.    if(mc.hit.hitTest(mc1) && mc1._currentframe == 2 && mc.stand)
  183.    {
  184.       _root.game_start = false;
  185.       _root.FNchogi2(_root.man);
  186.       mc1.gotoAndStop("into");
  187.    }
  188. };
  189. FNstay = function(mc, speed)
  190. {
  191.    if(_root.hurting == false)
  192.    {
  193.       if(mc.stand)
  194.       {
  195.          mc.gotoAndStop("stay");
  196.       }
  197.       else
  198.       {
  199.          mc.gotoAndStop("fly");
  200.       }
  201.    }
  202. };
  203. FNeat = function(mc)
  204. {
  205.    var _loc2_ = 1;
  206.    while(_loc2_ <= item_num)
  207.    {
  208.       if(mc.hit.hitTest(_root.back["o" + _loc2_]) && _root.back["o" + _loc2_]._currentframe != 8)
  209.       {
  210.          _root.count_num = _root.count_num + 1;
  211.          _root.back["o" + _loc2_].gotoAndStop("ok");
  212.       }
  213.       _loc2_ = _loc2_ + 1;
  214.    }
  215.    if(_root.count_num == item_num && _root.back.door._currentframe == 1)
  216.    {
  217.       _root.back.door.gotoAndStop(2);
  218.    }
  219. };
  220. FNhurt = function(mc, mc1)
  221. {
  222.    var _loc2_ = 1;
  223.    while(_loc2_ <= enemy_num)
  224.    {
  225.       if(mc.hit.hitTest(_root.back["enemy" + _loc2_].hit) && mc._currentframe != 5 && _root.hurting == false)
  226.       {
  227.          _root.hurting = true;
  228.          mc.gotoAndStop("hurt");
  229.          mc1.gotoAndStop(5);
  230.          _root.game_start = false;
  231.       }
  232.       if(mc.hit.hitTest(_root.back["enemy" + _loc2_].rec) && mc._currentframe != 5)
  233.       {
  234.          trace("δ╢Çδö¬φ₧êδïñ");
  235.          _root.back["enemy" + _loc2_].gotoAndPlay("stop");
  236.       }
  237.       _loc2_ = _loc2_ + 1;
  238.    }
  239. };
  240. this.onEnterFrame = function()
  241. {
  242.    if(_root.game_start)
  243.    {
  244.       _root.menu_mc.time_bar.bar._xscale -= _root.time_num;
  245.       if(_root.menu_mc.time_bar.bar._xscale <= 0)
  246.       {
  247.          _root.menu_mc.life.nextFrame();
  248.          if(_root.menu_mc.life._currentframe != 4)
  249.          {
  250.             _root.menu_mc.time_bar.bar._xscale = 100;
  251.          }
  252.          else
  253.          {
  254.             _root.menu_mc.time_bar.bar._xscale = 0;
  255.          }
  256.       }
  257.       _root.man2._x = _root.man._x + 20;
  258.       _root.man2._y = _root.man._y - 2;
  259.       _root.man2.gotoAndStop(_root.man._currentframe);
  260.       current = _root.man.mc_in.bubble._currentframe;
  261.       if(Key.isDown(37))
  262.       {
  263.          FNleft(_root.man,_root.man.speedX);
  264.          _root.man._xscale = 130;
  265.          _root.man2._xscale = _root.man._xscale + 30;
  266.       }
  267.       if(Key.isDown(39))
  268.       {
  269.          FNright(_root.man,_root.man.speedX);
  270.          _root.man._xscale = -130;
  271.          _root.man2._xscale = _root.man._xscale - 30;
  272.       }
  273.       if(Key.isDown(32))
  274.       {
  275.          if(sound_ok)
  276.          {
  277.             sound4.start();
  278.          }
  279.          sound_ok = false;
  280.          FNup(_root.man,_root.man.speedY,_root.man2);
  281.       }
  282.       else
  283.       {
  284.          sound_ok = true;
  285.          FNdown(_root.man,_root.man.speedY,_root.man2);
  286.       }
  287.       if(Key.isDown(39) == false && Key.isDown(37) == false)
  288.       {
  289.          FNstay(_root.man,_root.man.speedY);
  290.       }
  291.       if(Key.isDown(38))
  292.       {
  293.          FNgoal(_root.man,_root.back.door);
  294.       }
  295.       FNeat(_root.man);
  296.       FNhurt(_root.man,_root.man2);
  297.    }
  298. };
  299.