1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-24 16:44:20 +00:00
swear-jar/game_camera.gd
2023-10-02 15:12:52 +02:00

20 lines
501 B
GDScript

extends Camera2D
class_name GameCamera
func set_camera_position(scaling_factor: float):
var cutouts: Array[Rect2] = DisplayServer.get_display_cutouts()
var bottom
if len(cutouts) == 0:
bottom = 8
else:
var screen: Vector2i = DisplayServer.screen_get_size()
var rect: Rect2i = DisplayServer.get_display_safe_area()
bottom = max(8, screen.y - rect.end.y)
print("[GameCamera] Bottom margin is: ", bottom)
var size = get_window().size.y / scaling_factor
position.y = 480 - (size / 2)