Directions: Enable gravity to determine the bounciness of each ball. Each ball represents a different type of ball: 1) bowling ball 2) tennis ball 3) basket ball. Can you figure out which ball is which based on their bounciness? 

Purpose:
This project was my final submission to complete Unity's Jr. Programmer Pathway. It demonstrates Object Oriented Programming principles such as

Abstraction (The use of removing complex code / calling on methods)
Inheritance (The use of a parent class providing features to a child class)
Polymorphism (Overriding the features of the parent class with unique features)
Encapsulation (Protecting lines of code so values cannot be corrupted)

I also had to use Github to create a repository and differing branches.

Methodology:

  • For Abstraction, I created the Enable Gravity button, which uses my BallDrop() method. This method utilizes the EnableGravity() function from each of the balls.
  • For Inheritance I created a BallMovement class. Each of the type of balls were made a child of this class, and all were able to access the EnableGravity() function from the parent class
  • For Polymorphism, I made each ball contain a override method that overrode the level of bounciness from the parent class. As a result, each ball contained a different level of bounciness. 
  • For Encapsulation, I protected the time setting for the dollar sign to disappear. I made it display an error message if the developer accidentally put a negative time (for example, -3 instead of 3).

Additional notes:

  • For some reason, making the build into a WEBGL build messes up the position of the buttons and the text. I still need to improve on this.
  • Sometimes the coroutine does not start in the WEBGL build, but it shows no issues in the editor side. Not really sure what's the problem here either.

Leave a comment

Log in with itch.io to leave a comment.