Pingar is an iOS app where the user can play a game of table tennis in augmented reality. Two modes are available, singleplayer and multiplayer.
The following technologies were used in the project.
- ARKit 3 – For the augmented reality scene
- GameplayKit – For the bot AI behaviour
- SceneKit – Used for simulating physics such as gravity and collision
- StoreKit – Handling of In-App-Purchases
- GoogleMobileAds – For interstitial add
- MultipeerConnectivity – For communicating via bluetooth between the devices
- CoreData – For saving the user preferences
- JSVKit – My own library with lots of helper code
The architecture of the application consists of a state machine which keeps track of what playing state the game is currently in (Setup, Starting, Playing, Ended). Depending on the state, the user interactions will give different results.
It’s build around a command type pattern (which is very common in games). One major advantage is that a command is easily replayed on any other device that is connected.
Replaying the commands are not enough though, the physics need to be synced. The reason for that is because very small variations in speed, rotation and timing can result in drastically different environments over time. Therefore, the world is synced every frame. The sync packages are optimised to be as small as possible (with encoding them in a bit stream) and appended to a queue to later be executed. The last step is to make sure that the sync packages are executed in the correct order.
The application has both UI and unit tests and is configured with TravisCI.
Free download available on the App Store.