Code in frame 1 layer 1


//platform scrolling game

//scroller.fla

//By Andy Harris, Dummies Guide to Game Programming in Flash



init();



function init(){

  guy.speed = 3;

  guy.dx = 0;

  guy.dy = 0;

  guy.jumping = false;

} // end init



guy.onEnterFrame = function(){

  //check keys

  if(Key.isDown(Key.RIGHT)){

    guy._x += guy.speed;

  } // end if



  if(Key.isDown(Key.LEFT)){

    guy._x -= guy.speed;

  } // end if



  //jump

  if(Key.isDown(Key.UP)){

    if(guy.jumping == false){

      guy.jumping = true;

      guy._y -= 5;

      guy.dy = -5;

    } // end if



  } // end if



  guy.dy += .5;



  //guy hits ground

  if (land.hitTest(guy._x, guy._y, true)){

    guy.jumping = false;

    if(guy.dy > 10){

      trace("squash");

    } // 

    guy.dy = 0;



  } // end if 



  guy._y += guy.dy;



} // end enterFrame