# \[help\]platform game,character stops earlier before collision to right wall

**URL:** <https://forum.kirupa.com/t/help-platform-game-character-stops-earlier-before-collision-to-right-wall/300861>\
**Category:** flash\
**Created:** [November 29, 2009, 6:01am UTC](https://forum.kirupa.com/t/help-platform-game-character-stops-earlier-before-collision-to-right-wall/300861 "2009-11-29T06:01:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ash\_at\_risk](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@ash\_at\_risk](https://forum.kirupa.com/u/ash_at_risk)\
**Post date:** [November 29, 2009, 6:01am UTC](https://forum.kirupa.com/t/help-platform-game-character-stops-earlier-before-collision-to-right-wall/300861/1 "2009-11-29T06:01:00Z")

</div>

hi guys,  
I m under the process to create a platform based game,but stuck in a problem ,its probably concern with x-axis, actually my player stops certain distance before right wall and with left wall too,i tried to reduce the distance but end up in failure,i have attached the concern fla.

```php
function moveman(Char:Object, timediff:int)
        {
            if(timediff<1)
            return;
            var vertical:Number=Char.dy + gravity*timediff;  
            if (vertical>15.0)
            vertical=15.0;
                Char.dy+= timediff*gravity;
                var horizontalDist:Number=0;
                var newDirection:int=Char.direction;
                var newAnimstate:String="stand";
                if (Char.moveLeft)
                {
                    horizontalDist=-Char.walkspeed * timediff;
                    newAnimstate="walk";
                    newDirection=-1;
                }
                else if(Char.moveRight)
                {    
                    horizontalDist=Char.walkspeed*timediff;
                    newAnimstate="walk";
                    newDirection=1;
                }
                 if(Char.jump)
                {
                    Char.jump=false;
                    Char.dy=-Char.jumpspeed;
                    vertical=-Char.jumpspeed;
                    newAnimstate="jump";
                }
 
                var newY:Number= Char.mc.y + vertical;
                var newX:Number= Char.mc.x+ horizontalDist;
                Char.inAir=true;
    for (var j:int=0;j<wal.length; j++)
    {  
            if ((Char.mc.x+Char.width/2 >wal[j].leftside) && (Char.mc.x-Char.width/2<wal[j].rightside))   
            { 
                   if ((Char.mc.y <= wal[j].topside)&& (newY>wal[j].topside))
                { 
                    newY=wal[j].topside-Char.width;
                    Char.inAir=false;
                    Char.dy=0;
                    break;
                }
               }
            }
   for (var j:int=0; j<wal.length; j++)
   {
     if((newY>wal[j].topside)&&(newY-Char.height<
wal[j].bottomside))
    {
     if (( (Char.mc.x- Char.width/2) >=wal[j].rightside) && ((newX-Char.width/2 )<= wal[j].rightside))
        {    
            newX=wal[j].rightside + Char.width/2;
            break;
        }
         if(((Char.mc.x+Char.width/2)<=wal[j].leftside) && (newX +Char.width/2>=wal[j].leftside))
        {
            newX=wal[j].leftside-Char.width/2;
            break;
        }
    }                    
  }
               Char.mc.x=newX;
                Char.mc.y=newY;
      }

```
