void Update() { if (gameOver) { Cursor.visible = true; if (Input.GetKey("return")) { string name = nameField.text; fa.append(name + " " + (bodies.Count - 1)); SceneManager.LoadScene("Menu"); } return; } elapsedTime += Time.deltaTime; if (elapsedTime > moveTime) { updateBody(); elapsedTime = 0; for (int i = 1; i < bodies.Count; i++) { if (bodies[i].transform.position == bodies[0].transform.position) { gameOver = true; highScoreForm(); } } if (gameOver) { Debug.Log("Game Over "); } } if (Input.GetKey("escape")) { gameOver = true; Cursor.visible = true; SceneManager.LoadScene("Menu"); } float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); if (canPressButton) { if (horizontal >= sensitivity) { direction = Direction.LEFT; } else if (horizontal <= -sensitivity) { direction = Direction.RIGHT; } else if (vertical >= sensitivity) { direction = Direction.UP; } else if (vertical <= -sensitivity) { direction = Direction.DOWN; } } else { direction = Direction.NOPE; } canPressButton = (horizontal <= sensitivity && horizontal >= -sensitivity) && (vertical <= sensitivity && vertical >= -sensitivity); switch (direction) { case Direction.LEFT: snakeHead.transform.Rotate(left); break; case Direction.RIGHT: snakeHead.transform.Rotate(-left); break; case Direction.UP: snakeHead.transform.Rotate(-down); break; case Direction.DOWN: snakeHead.transform.Rotate(down); break; default: break; } }