SwiftUI Game

A little arcade game that uses SwiftUI as a game engine.

15
1
Swift

SwiftUI Game

A little arcade game that uses SwiftUI as a game engine ๐Ÿ˜ƒ

iPadOS Swift 5.3 SwiftUI 2.0 Swift Playgrounds 3 License: MIT

Video

Just copy the code into the Blank playgroundbook in Swift Playgrounds app on iPad or Mac and run it!

Do not forget to turn off Enable Results in the settings of the playgroundbook, otherwise the game will not run.

For some reason the code will not run in an Xcode Playgroud. Iโ€™ve created an issue.

Notes

This isnโ€™t the most beautiful Swift code. I made it just for fun and to learn a couple of things about SwiftUI.
I think a videogame is a good crash test for any UI framework ๐Ÿ˜ƒ
All the game logic (as well as almost all the animations) is done manually by changing @State vars in onReceive callbacks from the Timer.
Sometimes you may see glitches that are most likely caused by imperfect threading.