So I have this code here for a game with only left and right movement. I built in a clamp function so I don't have to bother with collision and walls (most of it is point, click and L/R movement).
My clamp function so far is working as needed. I am using a function to catch screen size at ready and have a "margin" variable to export at the top of this movement script's parent object:
direction.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
var movement = direction * speed * delta
var x_limit_l = (0 - ((screen_size.x/2)-marg))
var x_limit_r = ((screen_size.x/2)-marg)
position.x = clamp(position.x, x_limit_l, x_limit_r)
My levels will have a very controlled size and I am working in letterbox format. However I am wondering if this coding will be a problem once I do longer rooms. Is there a way to adjust this for level size vs screen size or am I better off just dragging collision boxes into every single room? (This would be a pain as I am using a procedural generation engine of sorts).