File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -272,16 +272,17 @@ Transform2D Camera2D::get_camera_transform() {
272272 Rect2 screen_rect (-screen_offset + ret_camera_pos, screen_size * zoom_scale);
273273
274274 if (limit_enabled && (!position_smoothing_enabled || !limit_smoothing_enabled)) {
275+ Point2 bottom_right_corner = Point2 (screen_rect.position + 2.0 * (camera_pos - screen_rect.position ));
275276 if (screen_rect.position .x < limit[SIDE_LEFT]) {
276277 screen_rect.position .x = limit[SIDE_LEFT];
277278 }
278279
279- if (screen_rect. position . x + screen_rect. size .x > limit[SIDE_RIGHT]) {
280- screen_rect.position .x = limit[SIDE_RIGHT] - screen_rect.size . x ;
280+ if (bottom_right_corner .x > limit[SIDE_RIGHT]) {
281+ screen_rect.position .x = limit[SIDE_RIGHT] - (bottom_right_corner. x - screen_rect.position . x ) ;
281282 }
282283
283- if (screen_rect. position . y + screen_rect. size .y > limit[SIDE_BOTTOM]) {
284- screen_rect.position .y = limit[SIDE_BOTTOM] - screen_rect.size . y ;
284+ if (bottom_right_corner .y > limit[SIDE_BOTTOM]) {
285+ screen_rect.position .y = limit[SIDE_BOTTOM] - (bottom_right_corner. y - screen_rect.position . y ) ;
285286 }
286287
287288 if (screen_rect.position .y < limit[SIDE_TOP]) {
You can’t perform that action at this time.
0 commit comments