Ball Battle

No more quarrels. Just battle.

Developed by Lu Han, Huake He

Mission of the project

Facilitate the harmony between you and your housemates during this pandemic

Week 1 - May 4

Discussion on how to implement the game, how it can be multiplayer, about using bluetooth or WIFI direct or firebase for real time data transmission.

Week 2 - May 11

We studied deep into the rolling ball demo, and got a complete understanding of how the sensor sensed the leaning of the phone, especially the onSensorChange method. We also had a discussion on whether to use motion sensor to control our ball.


Week 3 - May 18

We decided to use the motion Sensor in the rolling ball example, and wrote basic game logic for local player, including the generation of food and trap. In order to have a good game experience, we set the screen to always lock to landscape for display. After this week, the local game logic is completed.


Week 4 - May 25

We had a tough research on firebase, bluetooth, and WIFI direct, and ultimately decided on using firebase for real time data transmission. We have implemented the database of two balls and food and trap lists, and by constantly updating the locations of balls and foods and traps, we can generate real time game play.


Week 5 - June 1

In the last week, we finished up the lingering problem caused by different size phone screen, and It can display the locations on the database correctly on the local phone. We have also implemented the start page and end page to make the game more interactive.


Week 6 - June 8

Final Demo


API used:

We mainly depended on the Firebase database to realize real time data transmission between two devices. As the image shown on the right, the client (player 2) only updates its location information, and the server (player 1) gets the information and calculate all the food(target)/bomb(trap) processing and collision cases.

We used the phone's motion sensor as the method to control the movement of the ball


Challenges

The greatest challenge of this project is about firebase and internet lagging. At first, we have no idea how to use firebase beside the demo app, and we went though analyzing the firebase mechanism from all sources and familiarized with it. Due to a huge amount of information needs to be transferred as frequently as the sensor changes, we optimized the data storing and fetching by separating the server and client to only exchange needed information, and optimized the database structure to separate server client and food/trap list. The other big problem is internet lagging. Due to the nature of multiplayer game, we need very stable internet connection to record the ball and food/trap locations constantly. Because the data fetching/storing is executed on every sensor change (ball/food/trap location changes), so if any second the updated information is not stored/fetched correctly within a very short time period, the logics of the game maybe confused and create a misunderstanding and fail the game. In our debugging process, as long as the internet is not lagging, the game runs good, but when the ball movement is lagging, there can be unseen effects. We tried to optimize the data storing/fetching and now it reaches the minimum requirement.

Contact [luhan@ucsb.edu] to get more information on the project