Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AR Stack

demo

About

This app brings the popular game Stack into the real world with Augmented Reality. If you like this app or found it useful, I would appreciate if you starred it or even shared it with your friends. I don't expect to work on this too much more, as it was my first venture into AR and I came back to it because I had some free time.

Acknowledgments

The bulk of this code was written by Xander Xu in his tutorial. Because the Apache-2.0 license was included, I have taken the code and improved upon it. The basic functionality and logic is not mine, however, so most of the credit should go to him. If you would like to modify this app further, you are more than welcome to, as the same license is included, as long as all the rules regarding copyright, distribution, etc are followed.

Changes

  • The app shows you all detected planes and allows you to move the game location to within any of them.
  • The blocks now cycle through a random series of colors matched to the original game.
  • The session information label, debug options, and FPS bar have been hidden under the Debug button.
  • The AR Coaching Overlay view has been added to aid with establishing the scene instead.
  • A slight shadow has been added to the text so it is hopefully easier to see.
  • The GameScene was raised so the game never goes below the plane you are playing it on.
  • In addition to sounds, there are also some slight haptics that you can feel.
  • Person segmentation has been added while a game is active so your hand could be occluded.
  • The app now displays your high score in the top left. Can you beat my record of 51?
  • There is now an app icon, which I might have taken from the original Stack game.
  • The launch screen is a little bit nicer and the main screen takes up the full screen.
  • The app's settings have been updated according to Xcode's recommendations.
  • The code itself has been commented fully with the help of ChatGPT, and MARK lines label each section.

Installation

  1. Clone this repository or download it as a zip folder and uncompress it.
  2. Open up the .xcodeproj file, which should automatically launch Xcode.
  3. You might need to change the signing of the app from the current one.
  4. Click the Run button near the top left of Xcode to build and install.

Prerequisites

Hopefully this goes without saying, but you need Xcode, which is only available on Macs.

Notes

You must connect a physical device to your computer to run this, as a simulator does not support AR tracking.
The device must be either an iPhone or iPad running iOS 16.0 or newer.

SDKs

  • ARKit - Integrate hardware sensing features to produce augmented reality apps and games.
  • SceneKit - Create 3D games and add 3D content to apps using high-level scene descriptions.
  • UIKit - Construct and manage a graphical, event-driven user interface for your iOS, iPadOS, or tvOS app.
  • Swift - A powerful and intuitive programming language for all Apple platforms.

Bugs

If you find any, feel free to open up a new issue or even better, create a pull request fixing it.

Resolved

  • Coaching Overlay: might not have taken up the full screen on larger iPhones.
  • Sound Overhaul: per-effect AVAudioPlayers running off the main thread on a .playback session.
  • First-Block Stutter: pre-warmed feedback generators instead of one per event.
  • UIScene Launch Crash: adopted the UIScene life cycle newer SDKs require.
  • First-Install First-Tap Freeze: wait for camera access before session.run.
  • Crashes Fixed: people-occlusion fatalError, a mid-game render-thread race, and currentFrame force-unwraps.
  • Slice Glitches: fixed a tap/render-loop race that misaligned layers and a white flash from the new SCNBox.
  • Status UI In Sync: information label, coaching overlay, and Play button now always update together.
  • Degraded-Tracking Recovery: content rebuilds on recovery and plane detection re-enables after a game.
  • Game Never Paused: taps and block movement now gated on trackingState until it recovers.
  • Label Alignment: fixed the debug button's contentVerticalAlignment to match that of the status's.

Contributors

Sachin Agrawal: I'm a self-taught programmer who knows many languages and I'm into app, game, and web development. For more information, check out my website or Github profile. If you would like to contact me, my email is github@sachin.email.

License

This package is licensed under the Apache License.

Copyright 2023-2026 Sachin Agrawal

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

This app brings the popular game Stack into the real world with Augmented Reality.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages