Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (transform.position.x <= rightBorder.position.x)
        {
            //move the player right
            if (Input.GetKey(KeyCode.D)) // enum
            {
                transform.position += new Vector3(1 * speed, 0, 0);
                transform.Rotate(new Vector3(0, 0, -1 * rotSpeed));
            }
        }

        if (transform.position.x >= leftBorder.position.x)
        {
            //move the player left
            if (Input.GetKey(KeyCode.A))
            {
                transform.position += new Vector3(1 * -speed, 0, 0);
                transform.Rotate(new Vector3(0, 0, 1 * rotSpeed));
            }
        }


        if (lives <= 0)
        {
            gameLogic.StopTimer();
            sceneManagement.ChangeToScene("GameOver");
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        //move the player right
        if (Input.GetKey(KeyCode.D))
        {
            transform.position += new Vector3(1 * speed, 0, 0);
            transform.Rotate(new Vector3(0, 0, -1 * rotSpeed));
        }

        //move the player left
        if (Input.GetKey(KeyCode.A))
        {
            transform.position += new Vector3(1 * -speed, 0, 0);
            transform.Rotate(new Vector3(0, 0, 1 * rotSpeed));
        }

        if (lives <= 0)
        {
            gameLogic.StopTimer();
            sceneManagement.ChangeToScene("GameOver");
        }

        //restrict movement to the floor borders
    }