using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraControls : MonoBehaviour
{
    [SerializeField]
    private Transform gameImage;
    [SerializeField]
    private float moveSpeed = 7f;
    [SerializeField]
    private float leftLimit = -3f;
    [SerializeField]
    private float rightLimit = 3f;

    void Update()
    {
        // Get input from the keyboard (A, D, LeftArrow, RightArrow)
        float input = Input.GetAxis("Horizontal"); // Returns -1 for left, 1 for right, 0 for no input

        // Calculate the new position
        Vector3 newPosition = gameImage.transform.position - new Vector3(input * moveSpeed * Time.deltaTime, 0, 0);

        // Clamp the new position to the specified limits
        newPosition.x = Mathf.Clamp(newPosition.x, leftLimit, rightLimit);

        // Apply the new position to the image
        gameImage.transform.position = newPosition;
    }

}
