Skip to content

dantoso/ARBlocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 

Repository files navigation

ARBlocks

Hey there, I've created this prototype that serves as an experimental game. The game is an iOS AR experience for building with cubes (similiar to Minecraft). The game detects horizontal surfaces so you can place blocks on top of them, from there you can place blocks adjacent to one another or more on top of the detected plane. You can place blocks with different colors and remove unwanted blocks besides being able to save your creations for later retrieval.

How to play

First, you'll need a flat horizontal surface, could be your table or the floor depending on how reflective it is. The more opaque, bigger and flatter the better. Then, point your camera to the surface and soon the app will detect it and place a semi-transparent white plane on top of it. Now you're good to go:

Print

  • You can pick 1 of 5 colors to place a cube of that color wherever on top of the plane or adjacent to another cube.
  • To remove a block you select the trash tool and tap an existing block to remove it.
  • To select a cube (or multiple) choose the select tool (the icon is a scope for lack of a better SF Symbol) and tap existing blocks, they will become semi-transparent, indicating that they are selected, to deselect, simply tap is again.
  • To use the selected blocks as a blueprint for a new construction, use the hammer tool, now instead of placing a single block, you will place all the blocks you selected (using the first you selected as a starting point).
  • To save the selected blocks, tap the save button to the side of the hammer, give a name to your construction and save them.
  • To load a saved construction, simply tap the folder icon on the top left and choose the construction you want to load, the use the hammer tool to spawn as many of those as you'd like.

How it works

The HUD views and app presentation are all handled by SwiftUI, the AR logic and presentation is made using ARKit and SceneKit. Now, diving deeper into the architecture, I know it is not very scalable at its current state, but I made this app to be small and had limited time to study, plan, develop and test it.

I improvised 4 layers:

  • View and Publisher layer (views show the app's user interface, the publisher manages the communication between AR layer and View layer)
  • AR layer (objects responsible for the AR, plane detection and block and construction placing logic)
  • Database layer (self explanatory)
  • Model and Repository layer (the 2 together act as an interface for the publisher and view layers to access the database layer)

That's about it, to get a more detail oriented perspective on how I've developed all this, I've used docC comments to document almost all of my code.

About

iOS AR block building game

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages