2D multiplayer platformer using Godot Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

14 lines
532 B

using Godot;
public class Background : TextureRect
{
public override void _Process(float delta)
{
var offset = new Vector2(8, 8);
var tileSize = Texture.GetSize();
var viewportSize = GetViewport().Size;
var camera = LocalPlayer.Instance.GetNode<Camera2D>("Camera");
RectPosition = ((camera.GlobalPosition - viewportSize / 2) / tileSize).Floor() * tileSize - offset;
RectSize = ((viewportSize + offset) / tileSize + Vector2.One).Ceil() * tileSize;
}
}