Snake game built using Swift, playable on any browser using WebAssembly and on macOS.
UI built using Tokamak, which is a SwiftUI compatible framework for WebAssembly. Interaction with the DOM is done through JavaScriptKit. Built and bundles using Carton.
Source code for the browser UI in WebApp.
Since Tokamak is a SwiftUI compatible framework, a Mac app can be easily created without too much adjustments.
Source code for the mac version in SnakeMacApp.
The core library contains all the game logic. This imports TokamakShim, which uses SwiftUI for compatible platforms, TokamakDOM for web and TokamakGTK for Linux. Using conditional compilation (#if
), platform-specific functions are handled (e.g. using Foundation for macOS and JavaScriptKit for the web).
If you find any bugs or have any improvement suggestions, please open an issue first. If you get green light, you can open a pull request.
If you want to work on any open issues, just comment on the issue with your intentions. If you end up not working not working on it anymore, please comment again.
Licensed under MIT license.