This code (edit: does not work) to clamp the player’s position to the screen no matter how big or small you set your screen or whether the camera is moving.
func fix_player_position():
var screen = get_viewport_rect()
global_position = global_position.clamp(screen.position, screen.position + screen.size)
Enjoy!
-W