home *** CD-ROM | disk | FTP | other *** search
/ Champak 35 / jogo-disk-35.iso / Games / puppy_fetch.swf / scripts / frame_19 / DoAction.as
Text File  |  2007-03-01  |  5KB  |  218 lines

  1. stop();
  2. score1 = 0;
  3. score2 = 0;
  4. score3 = 0;
  5. score4 = 0;
  6. score5 = 0;
  7. score6 = 0;
  8. score7 = 0;
  9. score8 = 0;
  10. score9 = 0;
  11. score10 = 0;
  12. hint._visible = false;
  13. x1 = 240;
  14. x2 = 260;
  15. x3 = 250;
  16. y1 = 130;
  17. y2 = 160;
  18. y3 = 150;
  19. sekundy = 0;
  20. setne = 0;
  21. napis = "Score: " + score;
  22. timer = "time:   00:00";
  23. czasujemy = function()
  24. {
  25.    if(sekundy <= 9)
  26.    {
  27.       seconds = "0" + sekundy;
  28.    }
  29.    else
  30.    {
  31.       seconds = sekundy;
  32.    }
  33.    if(setne <= 9)
  34.    {
  35.       mili = "0" + setne;
  36.    }
  37.    else
  38.    {
  39.       mili = setne;
  40.    }
  41.    timer = "time:   " + seconds + ":" + mili;
  42.    if(setne <= 92)
  43.    {
  44.       setne += 4;
  45.    }
  46.    else
  47.    {
  48.       setne = 0;
  49.       sekundy++;
  50.    }
  51. };
  52. reset = function()
  53. {
  54.    score = 5000;
  55.    timer = "time:   00:00";
  56.    sekundy = 0;
  57.    setne = 0;
  58.    mapX = map._x;
  59.    mapY = map._y;
  60.    wziety = false;
  61.    gramy = false;
  62.    dog._visible = false;
  63.    gravity = 0;
  64.    horizontal = 0;
  65.    landed = false;
  66.    friction = 0.9;
  67.    dog.patyk._visible = false;
  68. };
  69. reset();
  70. this.onEnterFrame = function()
  71. {
  72.    if(gravity <= -15)
  73.    {
  74.       gravity = -15;
  75.    }
  76.    if(score <= 0)
  77.    {
  78.       score = 0;
  79.    }
  80.    napis = "Score: " + score;
  81.    if(gramy == true)
  82.    {
  83.       zegarek.play();
  84.    }
  85.    else
  86.    {
  87.       zegarek.gotoAndStop(1);
  88.    }
  89.    if(gramy == true)
  90.    {
  91.       score--;
  92.       czasujemy();
  93.       map._y += gravity;
  94.       map._x -= horizontal;
  95.       tlo._x -= horizontal / 3;
  96.       horizontal *= friction;
  97.       if(Key.isDown(39) && horizontal < 10)
  98.       {
  99.          horizontal += 2;
  100.          dog._xscale = 100;
  101.       }
  102.       else if(Key.isDown(37) && horizontal > -10)
  103.       {
  104.          horizontal -= 2;
  105.          dog._xscale = -100;
  106.       }
  107.       gravity--;
  108.       if(gravity < 0 && landed == false)
  109.       {
  110.          dog.gotoAndStop(3);
  111.       }
  112.       if(Key.isDown(32) && landed == true && gravity >= -4)
  113.       {
  114.          landed = false;
  115.          gravity = 10;
  116.          map._y += 10;
  117.          dog.gotoAndStop(2);
  118.       }
  119.       if(gravity <= -7)
  120.       {
  121.          dog.gotoAndStop(3);
  122.       }
  123.       if(map.hitTest(x1,y2,true) && map.hitTest(x2,y2,true) && map.hitTest(x3,y2,true))
  124.       {
  125.          gravity = 0;
  126.          landed = true;
  127.          dog.gotoAndStop(1);
  128.          map._y += 5;
  129.       }
  130.       if(map.hitTest(x2,y1,true) && map.hitTest(x2,y2,true) && map.hitTest(x2,y3,true))
  131.       {
  132.          landed = false;
  133.          horizontal = -5;
  134.          map._x += 10;
  135.       }
  136.       if(map.hitTest(x1,y1,true) && map.hitTest(x1,y2,true) && map.hitTest(x1,y3,true))
  137.       {
  138.          landed = false;
  139.          horizontal = 5;
  140.          map._x += -10;
  141.       }
  142.       if(map.hitTest(x1,y1,true) && map.hitTest(x1,y2,true) && map.hitTest(x2,y1,true) && map.hitTest(x2,y2,true) && dog._xscale == 100)
  143.       {
  144.          landed = true;
  145.          map._x += 10;
  146.       }
  147.       if(map.hitTest(x1,y1,true) && map.hitTest(x1,y2,true) && map.hitTest(x2,y1,true) && map.hitTest(x2,y2,true) && dog._xscale == -100)
  148.       {
  149.          landed = true;
  150.          map._x -= 10;
  151.       }
  152.       if(map.patyk.tester.hitTest(dog))
  153.       {
  154.          wziety = true;
  155.          map.patyk.gotoAndStop(2);
  156.          hint.nextFrame();
  157.       }
  158.       if(map.kamienie.hitTest(dog) && hint._currentframe == 3)
  159.       {
  160.          hint.nextFrame();
  161.       }
  162.       if(dog.hitTest(map.rzucenie) && wziety == true)
  163.       {
  164.          gramy = false;
  165.          map.rzucenie.play();
  166.          dog._visible = false;
  167.       }
  168.       z = 0;
  169.       while(z < 10)
  170.       {
  171.          eval("map.kot" + z).onEnterFrame = function()
  172.          {
  173.             if(this._x + _root.map._x >= 250)
  174.             {
  175.                this._xscale = 100;
  176.             }
  177.             else
  178.             {
  179.                this._xscale = -100;
  180.             }
  181.             if(this.tester.hitTest(_root.dog) && this._currentframe == 1)
  182.             {
  183.                _root.horizontal = (- _root.horizontal) * 2;
  184.                _root.gravity = Math.abs(_root.gravity) * 0.6;
  185.                this.play();
  186.             }
  187.          };
  188.          z++;
  189.       }
  190.       e = 0;
  191.       while(e < 10)
  192.       {
  193.          eval("map.gem" + e).onEnterFrame = function()
  194.          {
  195.             if(this.tester.hitTest(_root.dog))
  196.             {
  197.                _root.score += 500;
  198.                this.play();
  199.             }
  200.          };
  201.          e++;
  202.       }
  203.       e = 0;
  204.       while(e < 20)
  205.       {
  206.          eval("map.winda" + e).onEnterFrame = function()
  207.          {
  208.             if(this.hitTest(_root.dog))
  209.             {
  210.                _root.map._y += 2;
  211.                this.play();
  212.             }
  213.          };
  214.          e++;
  215.       }
  216.    }
  217. };
  218.