Controls: Use your Mouse (Left Click) to click on food randomly flying onto the screen. Avoid clicking on bombs, and make sure all the foods are clicked! 
Pizza = 1pt, Cookie = 2pt, Pear = 3pt. Bombs end the game.

Purpose: UI (Score, Difficulty, Restart)

  1. Create UI that updates the score whenever a food is clicked
  2. Create UI that restarts the game once it is over
  3. Create UI that features the Title and Game Over text when appropriate
  4. Create UI that changes the difficulty of the game
  5. Create objects that spawn at the bottom of the screen. Objects are acted with a random range of force, that spins with a random range of torque, and are from a random position at the bottom.


Methodology:

  1. Unity has a OnMouseDown method that detects when a mouse is being clicked. When clicked, it uses a function (UpdateScore) that passes through a point value. A point value is assigned to each food item. This point value is then added to the current score with a += operator, and this change is reflected on the score text via .text
  2. For the restart button to work, use Unity's LoadScene method that is available through UnityEngine.SceneManagement. The easiest way is to just get the current scene via GetActiveScene().name, since there is only one scene
  3. The Title Screen and the Game Over screen is controlled by different methods. When the game starts, the Title screen deactivated. When a fail condition is reached, the Game Over method is launched which activates the restart button and the game over text. 
  4. The difficulty is controlled by a script that determines which button was clicked via Unity's AddListener function. Depending on the button, a integer is passed as a parameter. This integer affects the spawn rate of the food through a /= operator. A difficulty of easy, passes through the integer of 1, which takes 2/1 = 2, which means 2 seconds between each food. Medium passes 2, which makes it 1 second in between spawns.
  5. To get a random amount of Torque, Force, and position, use AddForce, AddTorque, and transform.position. pass through Random.Range in each of the values and set min and max ranges.

Notes for the future: 

UI is challenging to program because the location of the text can change with different resolutions. There has to be a way to keep the size of the text and buttons to change relative to the size of the screen.


Leave a comment

Log in with itch.io to leave a comment.