{"id":17026756,"url":"https://github.com/chenanton/virtual-ball-pit","last_synced_at":"2025-08-21T08:17:17.868Z","repository":{"id":92108440,"uuid":"288315107","full_name":"chenanton/virtual-ball-pit","owner":"chenanton","description":"A simple two-dimensional physics engine simulating inelastic collisions between balls and their surroundings.","archived":false,"fork":false,"pushed_at":"2021-02-03T16:21:43.000Z","size":5056,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T19:17:19.624Z","etag":null,"topics":["balls","cpsc210","java","junit","physics","simulation","swing","ubc"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chenanton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-18T00:23:50.000Z","updated_at":"2021-02-03T16:21:45.000Z","dependencies_parsed_at":"2023-03-13T17:34:09.789Z","dependency_job_id":null,"html_url":"https://github.com/chenanton/virtual-ball-pit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/chenanton/virtual-ball-pit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenanton%2Fvirtual-ball-pit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenanton%2Fvirtual-ball-pit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenanton%2Fvirtual-ball-pit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenanton%2Fvirtual-ball-pit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenanton","download_url":"https://codeload.github.com/chenanton/virtual-ball-pit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenanton%2Fvirtual-ball-pit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271448405,"owners_count":24761441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["balls","cpsc210","java","junit","physics","simulation","swing","ubc"],"created_at":"2024-10-14T07:34:35.630Z","updated_at":"2025-08-21T08:17:17.851Z","avatar_url":"https://github.com/chenanton.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/chenanton/virtual-ball-pit\"\u003e\n        \u003cimg src=\"data/screenshots/header.png\" alt=\"Logo\" width=\"180\" \u003e\n    \u003c/a\u003e\n    \u003ch2 align=\"center\" \u003eVirtual Ball Pit\u003c/h2\u003e\n\n  \u003cp align=\"center\"\u003e\n    This program is a simple two-dimensional physics engine simulating inelastic collisions between balls and their surroundings. Term project for CPSC 210 (Software Construction) at the University of British Columbia.\n    \u003cbr /\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n![GIF](data/demos/ballpit_demo.gif)\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\n## Table of Contents\n\n* [Background](#background)\n* [Demo](#demo)\n* [Outline](#outline)\n  * [UML Design Diagram](#uml-design-diagram)\n  * [Class Hierarchy](#class-hierarchy)\n* [Roadmap](#roadmap)\n  * [Phase 1: Basic Model and User Interaction](#phase-1-program-functionality)\n  * [Phase 2: Data Persistence](#phase-2-data-persistence)\n  * [Phase 3: Graphical User Interface](#phase-3-graphical-user-interface)\n  * [Phase 4: Design](#phase-4-design)\n\u003c!-- * [Demo](#demo) --\u003e\n\n\u003c!-- BACKGROUND --\u003e\n\n## Background\n\n\u003c!-- [![Product Name Screen Shot][product-screenshot]](https://example.com) --\u003e\n\n\u003e _**What** does this application do?_\n\nThis project is able to simulate a 2 dimensional physical environment with object collisions under the effects of gravity and friction. In addition, objects may be \ncreated, saved, and loaded by a user, with specifiable physical attributes.\n\n\u003e _**Who** will use it?_\n\nThis project is primarily intended to be used by a younger demographic of students in an educational setting, where they can \"get their hands dirty\" and toy around with various physical phenomena.      \n\n\u003e _**Why** did I decide on this project idea?_\n\nI thought that it was a challenging task to translate theoretical concepts I learned from other classes into concrete code which can accurately explain real-world phenomena, particularly that of momentum. Not only will this help me gain a deeper understanding of these concepts, but will also allow me to practice object-oriented programming techniques to solve problems.\n\n\u003c!-- DEMO --\u003e\n\n## Demo\n\n### Create Ball Pit\n![GIF](data/demos/create_ballpit.gif)\n\n### Save Ball Pit\n![GIF](data/demos/save_ballpit.gif)\n\n### Load Ball Pit\n![GIF](data/demos/load_ballpit.gif)\n\n\n\u003c!-- OUTLINE --\u003e\n\n## Outline\n\n* This program is written in [**Java**](https://java.com/en/download/).\n* Unit testing is done with [**JUnit 5**](https://junit.org/junit5/).\n* GUI written with [**Swing**](https://en.wikipedia.org/wiki/Swing_(Java)).\n\n### UML Design Diagram\n\n\u003c!-- UML DESIGN DIAGRAM --\u003e\n\u003ca href=\"https://github.com/chenanton/virtual-ball-pit\"\u003e\n    \u003cimg src=\"data/screenshots/uml_diagram.png\" alt=\"Logo\" width=\"6000\" \u003e\n\u003c/a\u003e\n\n\u003c!-- CLASS HIERARCHY --\u003e\n### Class Hierarchy\n- _Matter_ is an abstract class holding generic information regarding objects within the environment (e.g. mass, speed, and position).\n- _Ball_ is a specific subclass of _Matter_, with properties specific to a ball (e.g. radius)\n- _BallPit_ is an aggregate class of all of _Matter_ objects, and environment characteristics (e.g. width, height). \n\n\u003c!-- ROADMAP --\u003e\n\n## Roadmap\n\n\n\u003c!-- ####Instructions for Grader\n - Step 1: create a new ball pit, or load the saved ball pit when opening the application\n - Step 2: to add ball to ball pit, click on settings icon, and add ball (or press \"A\")\n - Step 3: to trigger audiovisual component, use the arrow keys to make balls collide with each other\n - Step 4: to save ball pit, click save ball pit in settings.  --\u003e\n\n\n\u003c!-- PHASE 1 --\u003e\n### Phase 1: Program Functionality\nAs a user, some of the things I want the program to do are...\n- [x] see the balls _move_\n- [x] _add_ balls to the BallPit\n- [x] _delete_ balls from the BallPit\n- [x] see the balls _interact_ with each other and the environment\n\n\u003c!-- PHASE 2 --\u003e\n### Phase 2: Data Persistence\nAs a user, I want to features that allow me to...\n- [x] _save_ the current state of the sandbox locally\n- [x] _load_ another sandbox's state\n- [x] _prompt_ me to save when exiting the sandbox\n\n\u003c!-- PHASE 3 --\u003e\n### Phase 3: Graphical User Interface\n\nIn order to refactor the program from a console application to an application with a GUI, I implemented a _Main_ class to handle displaying the main menu with data persistence options, and a _PitPanel_ class to display the instantiated _BallPit_ object, along with corresponding controls.\n\n\u003c!-- PHASE 4 --\u003e\n### Phase 4: Design\n\n#### Code Robustness\nI chose to re-design a class such that it is robust. Particularly, I decided to use this on the _Ball_ class, such that balls with impossible mass and radius cannot be constructed. The methods which use this robust design are the constructors which create each ball.\n\n#### Cohesion and Coupling\nI chose to fix poor cohesion regarding the _Main_ class. In this particular class, one of the main issues is that in addition to running the main program (specifically ball pit related functions), this class had also included methods responsible for mouse events and key events. To solve this lack of cohesion, I made a separate class to handle mouse events and key events called _MainEventHandler_.\n\nA similar problem existed for the _PitPanel_ class, which should be responsible only for rendering the ball pit onto the JFrame. However, there was poor cohesion, as _PitPanel_ was also responsible for handling user input, in the form of key events and mouse events. To fix this poor cohesion, I made another class called _PitPanelEventHandler_ in order to handle key and mouse events from the user while the ball pit is being rendered.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenanton%2Fvirtual-ball-pit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenanton%2Fvirtual-ball-pit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenanton%2Fvirtual-ball-pit/lists"}