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

public class playercontroler : MonoBehaviour
{

    public float movespeed;
    public bool faceleft;



    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {

        // Move();
        //checkinput();
        if ( GameManager.instance.isgamestarted)
        {
            Move();
            checkinput();
        }
        if (transform.position.y <= -2) 
        {
            GameManager.instance.gameover();
        }
    }

    void Move()
    {
        transform.position += transform.forward *Time.deltaTime * movespeed;
    }
    void checkinput()
    {
        if (Input.GetMouseButtonDown(0))
        {
            checkdir();
        }
    }
    void checkdir()
    {
        if(faceleft)
        {
            faceleft = false;
            transform.rotation = Quaternion.Euler(0, 90, 0);


        }
        else
        {
            faceleft = true;
            transform.rotation = Quaternion.Euler(0, 0, 0);
        }
    }

}
