class GameLevelOne {

 var line_01:MovieClip;
 var line_02:MovieClip;
 var line_03:MovieClip;
 var line_04:MovieClip;
 var cylinder_01:MovieClip;
 var cylinder_02:MovieClip;
 var cylinder_03:MovieClip;
 var forbidden_area:MovieClip;
 var hits:Number = 0;
 var arrowVisible:Boolean = true;
 var arrowSuccessful:Number = 1;
 var checkpoint:Number = 0;
 var checkpointSound:Object;
 var isCheckpointSound_01:Boolean = true;
 var isCheckpointSound_02:Boolean = true;
 var isCheckpointSound_03:Boolean = true;
 var isCheckpointSound_04:Boolean = true;
 var isCheckpointSound_05:Boolean = true;
 var roundNumber:Number = 0;
 var isLevelCompleted:Boolean = true;
 var maximalRounds:Number = 3;


/***********************************************************************************************/
/*The constructor generates the jeep and the sound for the checkpoints (checkpoint.wav)*********/
/*Also it generates the first and second invisible checkpoints and the big arrow, to show*******/
/*the way for the player************************************************************************/
/***********************************************************************************************/

 public function GameLevelOne() {
  _root.attachMovie("truckOverhead", "jeep", 4);
  _root.jeep._x = 64;
  _root.jeep._y = 427; 
  
  _root.createEmptyMovieClip("sound_04", 5);
  checkpointSound = new Sound();
  checkpointSound.attachSound("checkpoint.wav"); 
  
  arrowSuccessfulOne();
  
 }
 
 public function arrowSuccessfulOne() {
  if ( arrowSuccessful == 1 ) {
   _root.attachMovie("checkpoint_01", "checkpoint_01_new", 3);
   _root.checkpoint_01_new._x = 263;
   _root.checkpoint_01_new._y = 220;
   
   _root.attachMovie("checkpoint_02", "checkpoint_02_new", 5);
   _root.checkpoint_02_new._x = 276;
   _root.checkpoint_02_new._y = 350;   
   
   _root.attachMovie("arrow_01", "arrow_01_new", 0);
   _root.arrow_01_new._x = 157;
   _root.arrow_01_new._y = 194;
  }  
 }
 
/************************************************************************************************/
/*After the Player goes successful through the first curve the second method arrowSuccessulTwo***/
/*will called************************************************************************************/
/*The 3. and 4. invisible checkpoints will generated. Also the second big arrow, to show the way*/
/************************************************************************************************/ 
 
 public function arrowSuccessfulTwo() {
  if ( arrowSuccessful == 2 ) {
   _root.attachMovie("checkpoint_03", "checkpoint_03_new", 3);
   _root.checkpoint_03_new._x = 485;
   _root.checkpoint_03_new._y = 365;
   
   _root.attachMovie("checkpoint_04", "checkpoint_04_new", 5);
   _root.checkpoint_04_new._x = 511;
   _root.checkpoint_04_new._y = 338;   
   
   _root.attachMovie("arrow_02", "arrow_02_new", 0);
   _root.arrow_02_new._x = 388;
   _root.arrow_02_new._y = 225;
  }
 }
 
/***********************************************************************************************/
/*The 5. and 6. invisible checkpoints will generated, also the 3. big arrow*********************/
/***********************************************************************************************/  
 
 public function arrowSuccessfulThree() {
  if ( arrowSuccessful == 3 ) {
   
   _root.attachMovie("checkpoint_05", "checkpoint_05_new", 3);
   _root.checkpoint_05_new._x = 725;
   _root.checkpoint_05_new._y = 220;
   
   _root.attachMovie("checkpoint_06", "checkpoint_06_new", 5);
   _root.checkpoint_06_new._x = 753;
   _root.checkpoint_06_new._y = 339;   
   
   _root.attachMovie("arrow_03", "arrow_03_new", 0);
   _root.arrow_03_new._x = 689;
   _root.arrow_03_new._y = 245;
  }
 } 
 
/***********************************************************************************************/
/*The 7. invisible checkpoints will generated, also the 4. big arrow****************************/
/***********************************************************************************************/  
 
 public function arrowSuccessfulFour() {
  if ( arrowSuccessful == 4 ) {
   
   _root.attachMovie("checkpoint_07", "checkpoint_07_new", 3);
   _root.checkpoint_07_new._x = 511;
   _root.checkpoint_07_new._y = 339;  
   
   _root.attachMovie("arrow_04", "arrow_04_new", 0);
   _root.arrow_04_new._x = 523;
   _root.arrow_04_new._y = 268;
  }
 } 
 
/***********************************************************************************************/
/*The 8. and 9. invisible checkpoints will generated, also the 5. big arrow*********************/
/***********************************************************************************************/  
 
 public function arrowSuccessfulFive() {
  if ( arrowSuccessful == 5 ) {
   
   _root.attachMovie("checkpoint_08", "checkpoint_08_new", 3);
   _root.checkpoint_08_new._x = 484;
   _root.checkpoint_08_new._y = 220;
   
   _root.attachMovie("checkpoint_09", "checkpoint_09_new", 5);
   _root.checkpoint_09_new._x = 280;
   _root.checkpoint_09_new._y = 338;   
   
   _root.attachMovie("arrow_05", "arrow_05_new", 0);
   _root.arrow_05_new._x = 330;
   _root.arrow_05_new._y = 174;
  }
 } 
 
/***********************************************************************************************/
/*This part controls onEnterFrame the hitTest() of all objects in Level 1***********************/
/***********************************************************************************************/ 
 
 public function onEnterFrame() {
  if ( _root.jeep.hitTest(_root.cylinder_01)       ||
    _root.jeep.hitTest(_root.cylinder_02)       ||
    _root.jeep.hitTest(_root.cylinder_03)       ||
    _root.jeep.hitTest(_root.line_01)           ||
    _root.jeep.hitTest(_root.line_02)           ||
    _root.jeep.hitTest(_root.line_03)           ||
    _root.jeep.hitTest(_root.line_04)          ||
    _root.jeep.hitTest(_root.forbidden_area)    ||
    _root.jeep.hitTest(_root.forbidden_area_02) ||
    _root.jeep.hitTest(_root.forbidden_area_03) ||
    _root.jeep.hitTest(_root.forbidden_area_04)   ){
   hits++;
  }
  
/***********************************************************************************************/
/*If the roundNumber is equal maximalRounds, the level is actually completed. The last arrow****/
/*and the last invisible checkpoint will be generated!******************************************/
/***********************************************************************************************/
   
  if ( roundNumber == maximalRounds ) { 
  
   if ( isLevelCompleted ) {
    isLevelCompleted = false;
    
    _root.attachMovie("arrow_finish", "arrow_finish_new", 0);
    _root.arrow_finish_new._x = 44;
    _root.arrow_finish_new._y = 276;
    
    _root.attachMovie("checkpoint_finish", "checkpoint_finish_new", 3);
    _root.checkpoint_finish_new._x = 23;
    _root.checkpoint_finish_new._y = 450;
    
   }
   
/***********************************************************************************************/
/*If the roundNumber is equal maximalRounds all the important objects like the car**************/
/*and the last invisible checkpoint and the big arrow will be deleted and all sounds will*******/
/*stopped. After that the root timeline goes to the Congratulation part*************************/
/***********************************************************************************************/   
   
   if ( _root.jeep.hitTest(_root.checkpoint_finish_new) ) {
    _root.checkpoint_finish_new.removeMovieClip();
    _root.arrow_finish_new.removeMovieClip();
    _root.jeep.removeMovieClip();
    stopAllSounds();
    
    _root.gotoAndPlay(\'Congratulation\');
    
   }   
   
  }
  
/***********************************************************************************************/
/*Here are the hitTest() of the 1. and 2. checkpoints*******************************************/
/***********************************************************************************************/
  
  if ( _root.jeep.hitTest(_root.checkpoint_01_new) ) {
   checkpoint = 1;
  }
  if ( _root.jeep.hitTest(_root.checkpoint_02_new) && checkpoint == 1 ) {
   checkpoint = 2;
   _root.arrow_01_new.removeMovieClip();
   
   if ( isCheckpointSound_01 ) {
    checkpointSound.start(0,1);
    isCheckpointSound_01 = false;
    arrowSuccessful = 2;
    arrowSuccessfulTwo();
   }
  }
  
/***********************************************************************************************/
/*Here are the hitTest() of the 3. and 4. checkpoints*******************************************/
/***********************************************************************************************/  
  
  if ( _root.jeep.hitTest(_root.checkpoint_03_new) && checkpoint == 2 ) {
   checkpoint = 3;

  }
  if ( _root.jeep.hitTest(_root.checkpoint_04_new) && checkpoint == 3 ) {
   checkpoint = 4;
   _root.checkpoint_03_new.removeMovieClip();
   _root.arrow_02_new.removeMovieClip();
   
   if ( isCheckpointSound_02 ) {
    checkpointSound.start(0,1);
    isCheckpointSound_02 = false;
    arrowSuccessful = 3;
    arrowSuccessfulThree();
   }
  } 
  
/***********************************************************************************************/
/*Here are the hitTest() of the 5. and 6. checkpoints*******************************************/
/***********************************************************************************************/  
  
  if ( _root.jeep.hitTest(_root.checkpoint_05_new) && checkpoint == 4 ) {
   checkpoint = 5;

  }
  if ( _root.jeep.hitTest(_root.checkpoint_06_new) && checkpoint == 5 ) {
   checkpoint = 6;
   _root.checkpoint_05_new.removeMovieClip();
   _root.arrow_03_new.removeMovieClip();
   
   if ( isCheckpointSound_03 ) {
    checkpointSound.start(0,1);
    isCheckpointSound_03 = false;
    arrowSuccessful = 4;
    arrowSuccessfulFour();
   }
  } 
  
/***********************************************************************************************/
/*Here are the hitTest() of the 7. checkpoint***************************************************/
/***********************************************************************************************/  
  
  if ( _root.jeep.hitTest(_root.checkpoint_07_new) && checkpoint == 6 ) {
   checkpoint = 7;
   _root.checkpoint_06_new.removeMovieClip();
   _root.arrow_04_new.removeMovieClip();
   
   if ( isCheckpointSound_04 ) {
    checkpointSound.start(0,1);
    isCheckpointSound_04 = false;
    arrowSuccessful = 5;
    arrowSuccessfulFive();
   }
  } 
  
/***********************************************************************************************/
/*Here are the hitTest() of the 8. and 9. checkpoints*******************************************/
/***********************************************************************************************/  
  
  if ( _root.jeep.hitTest(_root.checkpoint_08_new) && checkpoint == 7 ) {
   checkpoint = 8;

  }
  if ( _root.jeep.hitTest(_root.checkpoint_09_new) && checkpoint == 8 ) {
   checkpoint = 9;
   _root.checkpoint_08_new.removeMovieClip();
   _root.arrow_05_new.removeMovieClip();
   
   if ( isCheckpointSound_05 ) {
    checkpointSound.start(0,1);
    isCheckpointSound_05 = false;
    arrowSuccessful = 1;
    checkpoint = 0;
    isCheckpointSound_01 = true;
    isCheckpointSound_02 = true;
    isCheckpointSound_03 = true;
    isCheckpointSound_04 = true;
    isCheckpointSound_05 = true;
    roundNumber++;
    arrowSuccessfulOne();
   }
  }  
  
/***********************************************************************************************/
/*Here are the blinking animations for all arrows***********************************************/
/***********************************************************************************************/  
  
  if ( arrowSuccessful == 1 ||
    arrowSuccessful == 2 ||
    arrowSuccessful == 3 ||
    arrowSuccessful == 4 ||
    arrowSuccessful == 5 ) {
  
   if ( arrowVisible ) {
    _root.arrow_01_new._alpha     -= 5;
    _root.arrow_02_new._alpha     -= 5;
    _root.arrow_03_new._alpha     -= 5;
    _root.arrow_04_new._alpha     -= 5;
    _root.arrow_05_new._alpha     -= 5;
    _root.arrow_finish_new._alpha -= 5;
    
    if ( _root.arrow_01_new._alpha     < 30   ||
      _root.arrow_02_new._alpha     < 30   ||
      _root.arrow_03_new._alpha     < 30   ||
      _root.arrow_04_new._alpha     < 30   ||
      _root.arrow_05_new._alpha     < 30   ||
      _root.arrow_finish_new._alpha < 30  ) {
     arrowVisible = false;
    }
   }
   
   if ( arrowVisible == false ) {
    _root.arrow_01_new._alpha     += 5;
    _root.arrow_02_new._alpha     += 5;
    _root.arrow_03_new._alpha     += 5;
    _root.arrow_04_new._alpha     += 5;
    _root.arrow_05_new._alpha     += 5;
    _root.arrow_finish_new._alpha += 5;
    
    if ( _root.arrow_01_new._alpha     > 90    ||
      _root.arrow_02_new._alpha     > 90    ||
      _root.arrow_03_new._alpha     > 90    ||
      _root.arrow_04_new._alpha     > 90    ||
      _root.arrow_05_new._alpha     > 90    ||
      _root.arrow_finish_new._alpha > 90 ) {
     arrowVisible = true;
    }
   }
  }
  
/***********************************************************************************************/
/*If the user gets a hit point of 100, then the game is over and every**************************/
/*arrow and the jeep will deleted, and the timeline goes to the GameOver part!*****************/
/***********************************************************************************************/
  
  if ( hits > 100 ) {
   _root.arrow_01_new.removeMovieClip();
   _root.arrow_02_new.removeMovieClip();
   _root.arrow_03_new.removeMovieClip();
   _root.arrow_04_new.removeMovieClip();
   _root.arrow_05_new.removeMovieClip();
   _root.arrow_finish_new.removeMovieClip();
   _root.checkpoint_finish_new.removeMovieClip();   
   _root.jeep.removeMovieClip();
   _root.gotoAndPlay(\'GameOverLevelOne\');
  }
 }
}



class GameLevelTwo {
 
 var checkpointSound:Object;
 var line_05:MovieClip;
 var line_06:MovieClip;
 var line_07:MovieClip;
 var line_08:MovieClip;
 var cylinder_group_01:MovieClip;
 var cylinder_group_02:MovieClip;
 var cylinder_group_03:MovieClip;
 var cylinder_group_04:MovieClip;
 var cylinder_group_05:MovieClip;
 var isCheckpointSound_01:Boolean = true;
 var isCheckpointSound_02:Boolean = true;
 var isCheckpointSound_03:Boolean = true;
 var isCheckpointSound_04:Boolean = true; 
 var isCheckpointSound_05:Boolean = true;
 var hits:Number = 0;
 var arrowVisible:Boolean = true;
 var arrowSuccessful:Number = 1;
 var checkpoint:Number = 1;
 
 
/***********************************************************************************************/
/*The constructor generates the jeep and the sound for the checkpoints (checkpoint.wav)*********/
/*Also it generates the first invisible checkpoint and the big arrow, to show*******************/
/*the way for the player************************************************************************/
/***********************************************************************************************/
 
 public function GameLevelTwo() {
  _root.attachMovie("truckOverhead", "jeep", 4);
  _root.jeep._x = 50;
  _root.jeep._y = 627; 
  
  _root.createEmptyMovieClip("sound_04", 5);
  checkpointSound = new Sound();
  checkpointSound.attachSound("checkpoint.wav");
  
  arrowSuccessfulOne();
 }
 
 public function arrowSuccessfulOne() {
  _root.attachMovie("checkpoint_01_level_02", "checkpoint_01_new", 3);
  _root.checkpoint_01_new._x = 132;
  _root.checkpoint_01_new._y = 10;
  
  _root.attachMovie("arrow_01_level_02", "arrow_01_new", 0);
  _root.arrow_01_new._x = 42;
  _root.arrow_01_new._y = -25;  
 }
 
/************************************************************************************************/
/*After the Player goes successful through the first curve the second method arrowSuccessulTwo***/
/*will called************************************************************************************/
/*The 2. invisible checkpoint will generated. Also the second big arrow, to show the way*********/
/************************************************************************************************/ 
 
 public function arrowSuccessfulTwo() {
  _root.attachMovie("checkpoint_02_level_02", "checkpoint_02_new", 3);
  _root.checkpoint_02_new._x = 371;
  _root.checkpoint_02_new._y = 583;
  
  _root.attachMovie("arrow_02_level_02", "arrow_02_new", 0);
  _root.arrow_02_new._x = 286;
  _root.arrow_02_new._y = 498;  
 } 
 
/************************************************************************************************/
/*After the Player goes successful through the second curve the third method arrowSuccessulThree*/
/*will called************************************************************************************/
/*The 3. invisible checkpoint will generated. Also the third big arrow, to show the way**********/
/************************************************************************************************/ 
 
 public function arrowSuccessfulThree() {
  _root.attachMovie("checkpoint_03_level_02", "checkpoint_03_new", 3);
  _root.checkpoint_03_new._x = 608;
  _root.checkpoint_03_new._y = 121;
  
  _root.attachMovie("arrow_03_level_02", "arrow_03_new", 0);
  _root.arrow_03_new._x = 516;
  _root.arrow_03_new._y = 80;  
 } 
 
/************************************************************************************************/
/*After the Player goes successful through the third curve the fourth method arrowSuccessulFour**/
/*will called************************************************************************************/
/*The 4. invisible checkpoint will generated. Also the fourth big arrow, to show the way*********/
/************************************************************************************************/ 
 
 public function arrowSuccessfulFour() {
  _root.attachMovie("checkpoint_04_level_02", "checkpoint_04_new", 3);
  _root.checkpoint_04_new._x = 825;
  _root.checkpoint_04_new._y = 589;
  
  _root.attachMovie("arrow_04_level_02", "arrow_04_new", 0);
  _root.arrow_04_new._x = 738;
  _root.arrow_04_new._y = 493;  
 } 
 
/************************************************************************************************/
/*After the Player goes successful through the fourth curve the fifth method arrowSuccessulFive**/
/*will called************************************************************************************/
/*The parking checkpoint will generated.*********************************************************/
/************************************************************************************************/ 
 
 public function arrowSuccessfulFive() {
  _root.attachMovie("checkpoint_P_level_02", "checkpoint_P_new", 3);
  _root.checkpoint_P_new._x = 924;
  _root.checkpoint_P_new._y = 124;
  
 }  
 
/***********************************************************************************************/
/*Here is the hitTest() on every Frame for all objects in the second level**********************/
/*If the car hits an object the hits will increased 1 number************************************/
/***********************************************************************************************/ 
 
 public function onEnterFrame() {
 
  if ( _root.jeep.hitTest(_root.line_05)           ||
    _root.jeep.hitTest(_root.line_06)           ||
    _root.jeep.hitTest(_root.line_07)           ||
    _root.jeep.hitTest(_root.line_08)           ||
    _root.jeep.hitTest(_root.cylinder_group_01) ||
    _root.jeep.hitTest(_root.cylinder_group_02) ||
    _root.jeep.hitTest(_root.cylinder_group_03) ||
    _root.jeep.hitTest(_root.cylinder_group_04) ||
    _root.jeep.hitTest(_root.cylinder_group_05) ) {
   hits++;
  }
  
/***********************************************************************************************/
/*Here is the hitTest() of the 1. checkpoint****************************************************/
/***********************************************************************************************/
  
  if ( _root.jeep.hitTest(_root.checkpoint_01_new) && checkpoint == 1 ) {
   checkpoint = 2;
   _root.arrow_01_new.removeMovieClip();
   _root.checkpoint_01_new.removeMovieClip();
   
   if ( isCheckpointSound_01 ) {
    checkpointSound.start(0,1);
    isCheckpointSound_01 = false;
    arrowSuccessfulTwo();
   }
  } 
  
  
/***********************************************************************************************/
/*Here is the hitTest() of the 2. checkpoint****************************************************/
/***********************************************************************************************/
  
  if ( _root.jeep.hitTest(_root.checkpoint_02_new) && checkpoint == 2 ) {
   checkpoint = 3;
   _root.arrow_02_new.removeMovieClip();
   _root.checkpoint_02_new.removeMovieClip();
   
   if ( isCheckpointSound_02 ) {
    checkpointSound.start(0,1);
    isCheckpointSound_02 = false;
    arrowSuccessfulThree();
   }
  }  
  
/***********************************************************************************************/
/*Here is the hitTest() of the 3. checkpoint***************************************************/
/***********************************************************************************************/
  
  if ( _root.jeep.hitTest(_root.checkpoint_03_new) && checkpoint == 3 ) {
   checkpoint = 4;
   _root.arrow_03_new.removeMovieClip();
   _root.checkpoint_03_new.removeMovieClip();
   
   if ( isCheckpointSound_03 ) {
    checkpointSound.start(0,1);
    isCheckpointSound_03 = false;
    arrowSuccessfulFour();
   }
  }   
  
/***********************************************************************************************/
/*Here is the hitTest() of the 4. checkpoint***************************************************/
/***********************************************************************************************/
  
  if ( _root.jeep.hitTest(_root.checkpoint_04_new) && checkpoint == 4 ) {
   checkpoint = 5;
   _root.arrow_04_new.removeMovieClip();
   _root.checkpoint_04_new.removeMovieClip();
   
   if ( isCheckpointSound_04 ) {
    checkpointSound.start(0,1);
    isCheckpointSound_04 = false;
    arrowSuccessfulFive();
   }
  }  
  
/***********************************************************************************************/
/*Here is the hitTest() of the last checkpoint**************************************************/
/***********************************************************************************************/
  
  if ( _root.jeep.hitTest(_root.checkpoint_P_new) && checkpoint == 5 && _root.jeep.speed == 0 ) {
   _root.checkpoint_P_new.removeMovieClip();
   
   if ( isCheckpointSound_05 ) {
    checkpointSound.start(0,1);
    isCheckpointSound_05 = false;
    _root.jeep.removeMovieClip();
    stopAllSounds();
    _root.gotoAndPlay(\'Bravo\');
   }
  }   
  
  
/***********************************************************************************************/
/*Here are the blinking animations for all arrows***********************************************/
/***********************************************************************************************/  
  
   if ( arrowVisible ) {
    _root.arrow_01_new._alpha     -= 5;
    _root.arrow_02_new._alpha     -= 5;
    _root.arrow_03_new._alpha     -= 5;
    _root.arrow_04_new._alpha     -= 5;
    _root.checkpoint_P_new._alpha -= 5;
    
    if ( _root.arrow_01_new._alpha     < 30   ||
      _root.arrow_02_new._alpha     < 30   ||
      _root.arrow_03_new._alpha     < 30   ||
      _root.arrow_04_new._alpha     < 30   ||
      _root.checkpoint_P_new._alpha < 30 ) {
     arrowVisible = false;
    }
   }
   
   if ( arrowVisible == false ) {
    _root.arrow_01_new._alpha     += 5;
    _root.arrow_02_new._alpha     += 5;
    _root.arrow_03_new._alpha     += 5;
    _root.arrow_04_new._alpha     += 5;
    _root.checkpoint_P_new._alpha += 5;

    
    if ( _root.arrow_01_new._alpha     > 90    ||
      _root.arrow_02_new._alpha     > 90    ||
      _root.arrow_03_new._alpha     > 90    ||
      _root.arrow_04_new._alpha     > 90    ||
      _root.checkpoint_P_new._alpha > 90 ) {
     arrowVisible = true;
    }
   }
/***********************************************************************************************/
/*If the user gets a hit point of 20, then the game is over and every***************************/
/*arrow and the jeep will deleted, and the timeline goes to the GameOver part!******************/
/***********************************************************************************************/
  
  if ( hits > 20 ) {
   _root.arrow_01_new.removeMovieClip();
   _root.arrow_02_new.removeMovieClip();
   _root.arrow_03_new.removeMovieClip();
   _root.arrow_04_new.removeMovieClip();
   _root.checkpoint_P_new.removeMovieClip();   
   _root.jeep.removeMovieClip();
   _root.gotoAndPlay(\'GameOverLevelTwo\');
  }   
 }
}



class Car extends MovieClip {

 var speed:Number = 1;
 var rotationStep:Number = 7;
 var maxSpeed:Number = 10;
 var speedMaximum:Number = 10;
 var backSpeedMaximum:Number = -2;
 var speedx:Number;
 var speedy:Number;
 var rotationJeep:Number;
 var wheel_left:MovieClip;
 var wheel_right:MovieClip;
 var isAccelerating:Boolean = true;
 var isStill:Boolean = true;
 
 public function Car() {

 } 

/***********************************************************************************************/
/*This Method controlAnyKey() will be called on every Frame from the ControllableCar class,*****/
/*because this Method moves the car*************************************************************/
/***********************************************************************************************/
 
 public function controlAnyKey() {
  rotationJeep = this._rotation;
  speedx = Math.sin(rotationJeep * (Math.PI/180)) * speed;
  speedy = Math.cos(rotationJeep * (Math.PI/180)) * speed * -1;
 }
 
/***********************************************************************************************/
/*If the car is not faster than speedMaximum the speed will increased one unit!*****************/
/***********************************************************************************************/
 
 public function controlUpCar() {
  if ( speed <= speedMaximum ) {
   speed += 1;
  }
  
 }
 
/***********************************************************************************************/
/*If the car is faster than backSpeedMaximum the speed will reduced*****************************/
/***********************************************************************************************/
 
 public function controlDown() {
  if ( speed >= backSpeedMaximum ) {
   speed -= 0.5;
  }
 }
 
/***********************************************************************************************/
/*This Method is for the right direction of the car! Also the right wheel rotations*************/
/***********************************************************************************************/
 
 public function controlRight() {
  this._rotation += rotationStep*(speed / maxSpeed);
  
  if ( this.wheel_right._rotation < 24 ) {
   this.wheel_right._rotation += 6;
   this.wheel_left._rotation += 6;
  }
 }
 
/***********************************************************************************************/
/*If the right control is not active the wheels go back to the normal ( straight on ) position!*/
/***********************************************************************************************/
 
 public function controlRightFalse() {
  if ( this.wheel_right._rotation > 0 ) {
   this.wheel_left._rotation -= 6;
   this.wheel_right._rotation -= 6;   
  }
 }
 
/***********************************************************************************************/
/*This Method is for the left direction of the car! Also the left wheel rotations***************/
/***********************************************************************************************/ 
 
 public function controlLeft() {
  this._rotation -= rotationStep*(speed / maxSpeed);
  
  if ( this.wheel_left._rotation > -24 ) {
   this.wheel_left._rotation -= 6;
   this.wheel_right._rotation -= 6;
  }
 }
 
/***********************************************************************************************/
/*If the left control is not active the wheels go back to the normal ( straight on ) position!**/
/***********************************************************************************************/ 
 
 public function controlLeftFalse() {
  if ( this.wheel_left._rotation < 0 ) {
   this.wheel_left._rotation += 6;
   this.wheel_right._rotation += 6;   
  }
 }
 
/***********************************************************************************************/
/*If the key up button is not active, the car is stopping slowly!*******************************/
/***********************************************************************************************/
 
 public function controlCheckForwardCar() {
  if ( speed > 0 ) {
   speed -= 0.5;
  }
 }
 
/***********************************************************************************************/
/*If the key down button is not active, the car is stopping slowly!*****************************/
/***********************************************************************************************/ 
 
 public function controlCheckBackward() {
  if ( speed < 0 ) {
   speed += 0.5;
  }
 }
}



class SoundCar extends Car {
 
 var soundUp:Object;
 var engineSound:Object;
 var hornSound:Object;
 
/***********************************************************************************************/
/*The accelerating sound soundUp and the engine sound of the car will generated in the**********/
/*constructor***********************************************************************************/
/***********************************************************************************************/

 public function SoundCar() {
  _root.createEmptyMovieClip("sound_01", 1);
  soundUp = new Sound(_root.sound_01);
  soundUp.attachSound("up2speed.wav");
  
  _root.createEmptyMovieClip("sound_02", 2);
  engineSound = new Sound(_root.sound_02);
  engineSound.attachSound("Diesel.wav");
 
 }
 
/***********************************************************************************************/
/*The accelerating sound of the car starts here and the engine sound stops!*********************/
/***********************************************************************************************/
 
 public function controlUpSoundCar() {
  engineSound.stop();
  isStill = true;
  
  if ( isAccelerating ) {
   soundUp.start(0, 999);
   isAccelerating = false;
  }
   
 }
 
/***********************************************************************************************/
/*If the car doesn\'t drive the accelerating sound is stopped and the engine sound appears!******/
/***********************************************************************************************/

 public function controlCheckForwardSoundCar() {
  soundUp.stop();
  isAccelerating = true;

  if ( isStill ) {
   engineSound.start(0, 999);
   isStill = false;
  }

 } 
 
}



class ControllableCar extends SoundCar {
 
 public function ControllableCar() {
  
 }

/***********************************************************************************************/
/*Here are all the key controls on every Frame! And on every key down event a Method in the Car*/
/*class will called! The Method controlAnyKey() will called on every Frame in the Car class*****/
/***********************************************************************************************/
 
 public function onEnterFrame() {
 
   this._x += this.speedx;
   this._y += this.speedy;
   this.controlAnyKey();
 
   if (Key.isDown(Key.DOWN) == true) {
    this.controlDown();
   }
   if (Key.isDown(Key.UP) == false) {
    this.controlCheckForwardCar();
    this.controlCheckForwardSoundCar();
   }
   if (Key.isDown(Key.DOWN) == false) {
    this.controlCheckBackward();
   }
   if (Key.isDown(Key.UP) == true) {
    this.controlUpCar();
    this.controlUpSoundCar();
   }
   if (Key.isDown(Key.LEFT) == true) {
    this.controlLeft();
   }
   if (Key.isDown(Key.LEFT) == false) {
    this.controlLeftFalse();
   }
   if (Key.isDown(Key.RIGHT) == true) {
    this.controlRight();
   }
   if (Key.isDown(Key.RIGHT) == false) {
    this.controlRightFalse();
   }
 } 
}





top