void Update() { if (snakeScript.HasCollided() == true && shakeTime > 0) { transform.Translate(Vector3.right * Mathf.Sin(angle)); angle++; shakeTime -= Time.deltaTime; } else if (shakeTime < 0) { transform.position = originalPosition; } }
void Update() { if (snakeScript.HasCollided() == true) { if (Input.GetKeyDown(KeyCode.R)) { // Restart buttonEventsScript.ReloadGame(); } else if (Input.GetKeyDown(KeyCode.M)) { // Return to menu buttonEventsScript.LoadMainMenu(); } } // Change the snake's movement direction bool pressedRight; if (Input.GetKeyDown(KeyCode.L)) { pressedRight = true; ChangeSnakeDirection(pressedRight); } else if (Input.GetKeyDown(KeyCode.A)) { pressedRight = false; ChangeSnakeDirection(pressedRight); } // Set whether the food will next appear in the top or bottom half if (Input.GetKeyDown(KeyCode.W) && !accelerometerScript.IsTiltedDown()) { // Top half accelerometerScript.SetTiltedDown(true); } else if (Input.GetKeyDown(KeyCode.D) && !accelerometerScript.IsTiltedUp()) { // Bottom half accelerometerScript.SetTiltedUp(true); } }