Bubble Hero Engine
This is the game engine for the iOS game Bubble Hero, built with Swift 4 and latest API from iOS 11. It was built by Yunpeng in 2018.
This engine is published as a Cocoapod. Add the following line to your Podfile for usage:
pod 'GameEngine', :git => 'git@github.com:yunpengn/BubbleHeroEngine.git', :branch => 'master'
Design & Class Diagram

(Credit to ProcessOn for providing us with an excellent online tool to draw UML diagram)
This Bubble Hero Engine application follows the MVC (model, view, controller) architecture. Each component is explained as follows:
- Model: The model provides a reliable backend store for all the data in the game. Similar to Problem Set 3, a
Levelis composed of manyBubbles. By default, eachLevelhas 12 rows, 11/12 columns ofFilledBubbles. However, note that theLevelclass this type supports more functionalities compared to Problem Set 3.Stackis used to support some of these functionalities internally. In Problem Set 5, we may create subclasses forFilledBubblesince there are special bubbles. EachFilledBubblehas aBubbleType. For example,FilledBubbles of different colors are of differentBubbleTypes. Each object controlled by thePhysicsEnginemust be aGameObject. AGameObjectrepresents a simplified idealized physical object that obeys a certain subset of physics laws. In this problem set, it is a 2D object with no mass or volumn. However, it has a fixed size and its shape is a perfect circle. If itsisRigidBodyattribute istrue, then it becomes a rigid body. Collision may happen between two rigid bodies. AGameObjectcan have speed and acceleration, both of which can be seen as a 2D vector. TheBubbleProviderwill continously generate randomBubbleType, as a supplier for the bubble launcher. - Controller: The
BubbleArenaControlleris the main controller for the game view. To supportbubbleArenawhich is aUICollectionView, this class will conform toUICollectionViewDataSource,UICollectionViewDelegateandUICollectionViewDelegateFlowLayoutprotocols. TheBubbleLauncherControllercontrols the related operations and user input about launching a bubble (using the bubble launcher at the middle bottom of the screen). After a bubble has been launched, theShootingBubbleControllerwill take over the control. It will work closely withPhysicsEngineandGameObjectsControllerto instruct the movement of shooted bubbles and detect collision. Whenver collision happens, thePhysicsEnginewill informShootingBubbleControllerto handle the game-specific logic.GameObjectsControlleracts as a bridge and mapping between theGameObjects managed in the game engine andFilledBubbles stored in the model. For information passing and notification of events happened, delegate pattern is applied to the three main controllers. They conform toBubbleArenaControllerDelegate,BubbleLauncherControllerDelegateandShootingBubbleControllerDelegateprotocols respectively. - View: The view in this problem set is pretty simple. It mainly consists of two parts, the
BubbleArenaand theBubbleLauncher. TheBubbleArenais aUICollectionView, which is composed of manyBubbleCells, which conforms to theUICollectionViewCellprotocol. TheBubbleLauncheris simply aUIImageVIew, which shows the next bubble to be launched. Whenever the player shoots a bubble, it will be updated according to the supply fromBubbleProvider.
(The idea of rigid body & collision is adapted from Unity3D game engine, although there are variations.)
Acknowledgements
We would like appreciate the wonderful resources provided by the following websites:
- Flat Icons [https://www.flaticon.com]
- Pexels [https://www.pexels.com]
- ProcessOn [https://www.processon.com/]
- Unity3D Game Engine [https://unity3d.com/]