# How can you accurately simulate gravity with collisions?

`import flash.events.Event;addEventListener(Event.ENTER_FRAME, ef);s.rotation = -45; /*s is the object that the main object should collide with(It's like a static object, like a wall/slope)*///perpendicular = m • g • cos (45 degrees) = 6930 N - This is the main formulavar g:Number = 9.81 / 2; //Made g smaller to see the offset betterfunction ef(e:Event):void{    a.y += 1 * Math.sin(90 * Math.PI / 180) * g;        //a is the main object, it goes down with this line, this is the gravity force    if (a.hitTestObject(s))    {        var per:Number = 1 * g * Math.cos(45 * Math.PI / 180);                 //The formula        a.y += Math.sin((-45 - 90) * Math.PI / 180) * per;                 //-45 - 90 because I need to subtract 90 from the wall's angle to get the main objects sliding angle on the wall. This is the wall's force applied to the main object on the y axis.        a.x += Math.cos((-45 - 90) * Math.PI / 180) * per;                 //This is the wall's force applied to the main object on the x axis.    }}`