Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Apply Physics
- var speed_y,speed_x;
- //////////////////////
- ///Check for Y Axis///
- //////////////////////
- if(delta_time_get_steady() *obj_velocity_y < global.gravity_max){
- obj_velocity_y += delta_time_get_steady() * global.gravity_force * 1000;
- }
- //Get our current speed for this step on the y axis
- speed_y = delta_time_get_steady() * obj_velocity_y;
- //Is our next position going to collide?
- if(place_meeting(x,y+speed_y,obj_wall)){
- //if so, add one pixel until we do collide
- while(!place_meeting(x,y+sign(speed_y),obj_wall)){
- y += sign(speed_y);
- }
- obj_velocity_y = 0;
- speed_y = 0;
- }
- //apply calculated speed
- y = y + speed_y;
- //////////////////////
- ///Check for X Axis///
- //////////////////////
- //Add object acceleration
- obj_velocity_x += obj_accel_x;
- //Get the current speed for this step on the x axis
- speed_x = delta_time_get_steady() * obj_velocity_x;
- //Keep in bounds on x axis
- if(place_meeting(x+speed_x,y,obj_wall)){
- while(!place_meeting(x + sign(speed_x),y,obj_wall)){
- x += sign(speed_x);
- }
- obj_velocity_x = 0;
- speed_x = 0;
- }
- //Apply calculated speed
- x += speed_x;
- ////////////////////////////////
- ///Deaccelerate on the X Axis///
- ////////////////////////////////
- //if(place_meeting(x,y+1,obj_wall)){
- // obj_velocity_x = 0; // on ground so reset velocity
- //}else{
- // obj_velocity_x *= delta_time_get_steady() * 10; //
- //}
- obj_velocity_x = floor(obj_velocity_x + -sign(obj_velocity_x) * ( delta_time_get_steady() * 1000));
- obj_accel_x = 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement