Help me make Mario like game

Now for the scrolling! This is our final step in the art based platform tutorial! Ok, First of all, we need the code to go where? The “Char”, or “mario” in this case. So, we select mario and open his actions panel. Please type the following:


onClipEvent (enterFrame) {
 if (Key.isDown(Key.RIGHT)) {
  if (_root.mario._x>=300 //or whatever you decide to set for his positions//) {
   scroll = 5;
//setting his scrolling speed//
   xspeed = 0;
//ceasing his movement//
   this._x += 5;
   _root._x -= scroll;
   _root.score._x += scroll;
//notice "this", and "score", have different _x movement than "_root", that is because we dont want to make mario and the score scroll left and right :P//
  } else {
   xspeed = 5;
  }
 } else if (Key.isDown(Key.LEFT)) {
  if (_root.mario._x<=100 //or whatever you decide to set for his positions//) {
   scroll = 5;
   xspeed = 0;
   this._x -= 5;
   _root._x += scroll;
   _root.score._x -= scroll;
  } else {
   xspeed = 5;
  }
 }
}

 

This is the code that I recently came up with, and I hope that it help you :). If you have any questions, remember, I’m just a click away! Later!

peace.