using UnityEngine;

public class GroundMove : MonoBehaviour
{
    private SpriteRenderer _spriteRenderer;
    
    [SerializeField] private float speed = 1.5f;
    [SerializeField] private float moveLimit = 6f;

    private Vector2 _initalSize;
    
    void Start()
    {
        _spriteRenderer = GetComponent<SpriteRenderer>();
        _initalSize = new Vector2(_spriteRenderer.size.x, _spriteRenderer.size.y);
    }

    void Update()
    {
        _spriteRenderer.size = new Vector2(_spriteRenderer.size.x + (speed * Time.deltaTime), _spriteRenderer.size.y);
        
        if (_spriteRenderer.size.x > moveLimit)
        {
            _spriteRenderer.size = _initalSize;
        }
    }
}
