0 Replies Latest reply on Sep 26, 2010 11:01 AM by hppkllr3

    Help making Frogger like game

    hppkllr3

      I am trying to make a Frogger style game and am having some serious  issues. I have got it to where my character can pick up the person it's  supposed to and drop it off, but the item you pick up doesn't leave the  stage. I also cannot get the any of the vehicles or characters to spawn  using add child. Both of them need to spawn within certain ranges, and I  have no clue how to do that. I also have a fence that I want to impede  the player with a gate that I want to slide back and forth.

      My Library consists of fence movie clip, gate movie clip, player_mc,  person__mc, vehicle_mc. The Person and Vehicle Movie clips both have  three different images in them, and each is supposed to have different  values, IE, each vehicle is supposed to hit for more damage to the  player, and each person is worth a different value, 5-10-20 points. Here  is the code I have thus far, and I have no idea where to take it from  here.

      //Listeners
      stage.addEventListener(KeyboardEvent.K… keydown);
      stage.addEventListener(KeyboardEvent.K… keyup);
      stage.addEventListener(Event.ENTER_FRA… MovePlayer);
      stage.addEventListener(Event.ENTER_FRA… Collision);
      stage.addEventListener(Event.ENTER_FRA… Person);

      //variables
      //movement for left set to false
      var LeftBoolean:Boolean=false;
      //movement for right set to false
      var RightBoolean:Boolean=false;
      //movement for up set to false
      var UpBoolean:Boolean=false;
      //movement for down set to false
      var DownBoolean:Boolean=false;
      //players speed
      var PlayerSpeed:int = 5;

      var arePeopleonStage:Boolean=false;


      //var people:Person = new Person;

      //####################################…
      //Keydown Function
      function keydown(e:KeyboardEvent)
      {
      //if left arrow is pressed down
      if(e.keyCode==37)
      {//player moves left
      LeftBoolean=true;
      }
      //if right arrow is pressed down
      else if (e.keyCode == 39)
      {//player moves right
      RightBoolean = true;
      }
      //if up arrow is pressed down
      else if(e.keyCode == 38)
      {//player moves up
      UpBoolean = true;
      }
      //if down arrow is pressed down
      else if(e.keyCode == 40)
      {//player moves down
      DownBoolean = true;
      }
      }

      //KeyUp function
      //#################################
      function keyup(e:KeyboardEvent)
      {
      //if left arrow is not pressed down
      if(e.keyCode==37)
      {//player does not move left
      LeftBoolean=false;
      }
      //if right arrow is not pressed down
      else if (e.keyCode ==39)
      {//player does not move right
      RightBoolean=false;
      }
      //if up arrow is not pressed down
      else if(e.keyCode == 38)
      {//player does not move up
      UpBoolean=false;
      }
      //if down arrow is not pressed down
      else if(e.keyCode == 40)
      {//player does not move down
      DownBoolean = false;
      }
      }



      //Movement!
      //####################################…
      function MovePlayer(e:Event)
      {
      //if moving left
      if(LeftBoolean)
      {//player moves negative on the x axis
      Player_mc.x-=PlayerSpeed;
      }//if moving right
      if(RightBoolean)
      {//player moves posotive on the x axis
      Player_mc.x+= PlayerSpeed;
      }//if moving up
      if(UpBoolean)
      {//player moves negative on the y axis
      Player_mc.y-= PlayerSpeed;
      }//if moving down
      if(DownBoolean)
      {//player moves posotive on the y axis
      Player_mc.y+= PlayerSpeed;
      }
      }

      function Collision(e:Event)

      {//when player gets hit by truck
      if(Player_mc.hitTestObject(vehicle_mc…
      {//player restarts
      //sets players x to 37
      Player_mc.x = 37;
      //sets players y to 524
      Player_mc.y = 524;
      //tracing the collision
      trace("ACCIDENT!")
      }
      }

      function carryPerson(e:Event)
      {
      if(person_mc.y > 75)
      {
      person_mc.x = Player_mc.x;
      person_mc.y = Player_mc.y;
      }else{
      stage.removeEventListener(Event.ENTE… carryPerson);
      person_mc.x = 100;
      person_mc.y = 20;
      }
      }

      function Person(e:Event)
      {
      if(Player_mc.hitTestObject(person_mc)…
      {
      stage.removeEventListener(Event.ENTE… Person);
      stage.addEventListener(Event.ENTER_F… carryPerson);
      }
      }