Step_0.gml 763 B

1234567891011121314151617181920212223242526
  1. if instance_exists(follow)
  2. {
  3. x_to = follow.x;
  4. y_to = follow.y;
  5. }
  6. else
  7. {
  8. x_to = RES_W / 2;
  9. y_to = RES_H / 2;
  10. }
  11. shake_magnitude = lerp(shake_magnitude, 0, 0.05);
  12. if shake_magnitude < 1
  13. shake_magnitude = 0;
  14. var _x_delta = random_range(-shake_magnitude, shake_magnitude);
  15. var _y_delta = random_range(-shake_magnitude, shake_magnitude);
  16. var _target_x = clamp(x_to, bound_left + cam_width / 2, bound_right - cam_width / 2);
  17. x += (_target_x - x) * smooth * global.time_scale + _x_delta;
  18. var _target_y = clamp(y_to, bound_top + cam_height / 2, bound_bottom - cam_height / 2);
  19. y += (_target_y - y) * smooth * global.time_scale + _y_delta;
  20. var _cam_x = x - cam_width / 2;
  21. var _cam_y = y - cam_height / 2;
  22. camera_set_view_pos(view_camera[0], _cam_x, _cam_y);