home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Corrida / actiondrivinggame.swf / scripts / frame_2 / DoAction.as < prev   
Encoding:
Text File  |  2006-06-13  |  1.4 KB  |  67 lines

  1. function initialize()
  2. {
  3.    lives = 5;
  4.    cash = 0;
  5.    cashDisplay = 0;
  6.    gameState = "stop";
  7.    progress_bar_mc.gotoAndPlay(1);
  8. }
  9. function updateObstacle(obstacleTargetName)
  10. {
  11.    if(gameState == "play")
  12.    {
  13.       obstacleTargetName.play();
  14.    }
  15.    if(gameState == "stop")
  16.    {
  17.       obstacleTargetName.stop();
  18.    }
  19. }
  20. function testForCollision(xMin, xMax)
  21. {
  22.    if(car_mc._x >= xMin & car_mc._x <= xMax)
  23.    {
  24.       car_mc._y -= 6;
  25.       sound_mc.gotoAndPlay("crash");
  26.       lives -= 1;
  27.       if(lives == 0)
  28.       {
  29.          gotoAndPlay(88);
  30.       }
  31.    }
  32. }
  33. function testForCashCollision(xMin, xMax)
  34. {
  35.    if(car_mc._x >= xMin & car_mc._x <= xMax)
  36.    {
  37.       car_mc._y -= 6;
  38.       sound_mc.gotoAndPlay("cash_register");
  39.       cash += 10000;
  40.       num = String(cash).split(".");
  41.       commanum = "";
  42.       if(num.length == 2)
  43.       {
  44.          commanum = "." + num[1];
  45.       }
  46.       if(length(num[0]) > 3)
  47.       {
  48.          commanum = String(num[0]).substr(length(num[0]) - 3,3) + commanum;
  49.          digit = length(num[0]) - 6;
  50.          while(digit >= 0)
  51.          {
  52.             commanum = String(num[0]).substr(digit,3) + "," + commanum;
  53.             digit -= 3;
  54.          }
  55.          if(digit > -3)
  56.          {
  57.             commanum = String(num[0]).substr(0,digit + 3) + "," + commanum;
  58.          }
  59.       }
  60.       else
  61.       {
  62.          commanum = num[0] + commanum;
  63.       }
  64.       cashDisplay = commanum;
  65.    }
  66. }
  67.