{"id":49416582,"url":"https://github.com/nsevent/tilt-sim-experiment","last_synced_at":"2026-04-29T03:10:54.620Z","repository":{"id":339840847,"uuid":"1163566012","full_name":"NSEvent/tilt-sim-experiment","owner":"NSEvent","description":"A tilt simulator toy for Macbook. Tilt your Mac to change the direction of gravity.","archived":false,"fork":false,"pushed_at":"2026-02-21T21:34:00.000Z","size":5553,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-22T01:23:25.377Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://kevintang.xyz","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NSEvent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-21T20:27:26.000Z","updated_at":"2026-02-21T21:36:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/NSEvent/tilt-sim-experiment","commit_stats":null,"previous_names":["nsevent/tilt-sim-experiment"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/NSEvent/tilt-sim-experiment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NSEvent%2Ftilt-sim-experiment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NSEvent%2Ftilt-sim-experiment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NSEvent%2Ftilt-sim-experiment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NSEvent%2Ftilt-sim-experiment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NSEvent","download_url":"https://codeload.github.com/NSEvent/tilt-sim-experiment/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NSEvent%2Ftilt-sim-experiment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32408553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T02:37:21.628Z","status":"ssl_error","status_checked_at":"2026-04-29T02:36:50.947Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-29T03:10:52.685Z","updated_at":"2026-04-29T03:10:54.603Z","avatar_url":"https://github.com/NSEvent.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TiltSim\n\nA falling-sand game where you physically tilt your MacBook to control gravity.\n\nBuilt in Swift with zero dependencies. Reads the Apple Silicon accelerometer directly via IOKit to turn your laptop into a particle physics toy.\n\n12 elements (sand, water, lava, gunpowder, acid, ...) interact with each other — fire ignites wood and oil, lava solidifies on water contact, gunpowder chain-explodes, acid dissolves everything. Tilt your MacBook and watch it all flow.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"demo.gif\" alt=\"TiltSim demo — tilting MacBook to control gravity\" width=\"600\"\u003e\n\u003c/p\u003e\n\n## Quick Start\n\n```bash\ngit clone https://github.com/NSEvent/tilt-sim-experiment.git\ncd tilt-sim-experiment/tilt-sim-claude\nmake run\n```\n\nThat's it. `make run` builds and launches the app. Tilt control works automatically on Apple Silicon MacBooks.\n\n\u003e **No MacBook?** The app still works — gravity just always points down.\n\n### Requirements\n\n- macOS 14+ (Sonoma)\n- Swift 5.9+ (ships with Xcode or Xcode Command Line Tools)\n- Apple Silicon MacBook for tilt control (M1/M2/M3/M4)\n\n## Controls\n\n| Input | Action |\n|-------|--------|\n| **Left click + drag** | Draw selected element |\n| **Right click** (or Ctrl+click) | Erase |\n| **Scroll wheel** | Adjust brush size |\n| `[` / `]` | Decrease / increase brush size |\n| `1`–`9`, `0`, `-`, `=` | Select element |\n| `Space` | Pause / resume |\n| `D` | Toggle drain mode (particles removed at edges) |\n| `Cmd+Delete` | Clear all particles |\n\n## Elements\n\n| Element | Behavior |\n|---------|----------|\n| **Sand** | Falls, piles up, sinks through liquids |\n| **Water** | Flows and spreads laterally |\n| **Stone** | Immovable wall (destroyed by acid) |\n| **Wood** | Solid, flammable |\n| **Fire** | Rises, ignites wood/oil/gunpowder, melts ice |\n| **Smoke** | Rises and drifts, fades after 120 ticks |\n| **Lava** | Ignites flammable materials, turns to stone on water contact (+ steam) |\n| **Oil** | Floats on water, highly flammable |\n| **Acid** | Dissolves everything it touches |\n| **Steam** | Produced by lava+water, condenses back to water |\n| **Ice** | Melted by fire/lava into water |\n| **Gunpowder** | Explosive — chain detonation with radius 6, up to 20 chain reactions |\n\n## How the Tilt Works\n\nApple Silicon MacBooks have a built-in accelerometer (`AppleSPUHIDDevice`). The app reads raw sensor data via IOKit HID, applies exponential moving average smoothing, and maps the tilt angle to one of 8 gravity directions.\n\nThe gravity indicator in the top-right corner shows a dot representing the current tilt vector.\n\nNo special permissions required — the IOKit HID service is accessible without root.\n\n## How This Was Made\n\nThe code in `tilt-sim-claude/` was generated in a single shot by [Claude Code](https://claude.ai/claude-code) (Opus 4.6), using only [`SOURCE.md`](SOURCE.md) as input — a detailed spec describing the simulation rules, element interactions, rendering approach, and accelerometer integration. No manual editing afterward.\n\n## Regenerate It Yourself\n\nThe real source code is [`SOURCE.md`](SOURCE.md). The Swift files are just one possible output.\n\nFeed `SOURCE.md` to any AI model and ask it to generate the application:\n\n```\nGiven this spec, generate a complete macOS Swift Package Manager application.\n```\n\nFuture models will likely produce a better version than what's here today. The spec encodes the intent; the code is disposable.\n\nFor more on this idea, see [Backwards Compatible for Life](https://kevin.md/backwards-compatible-for-life.md) — on why specs and tests outlast implementations.\n\n## Architecture\n\n~1,500 lines of Swift across 10 files. No Xcode project — just Swift Package Manager.\n\n- **Grid**: 320x240 cell grid, each cell stores element type, color offset, lifetime, tick counter\n- **Simulation**: 60 ticks/sec fixed timestep. Processes cells bottom-up (flipped when gravity reverses). Random left/right scan order prevents directional bias\n- **Rendering**: Direct pixel buffer to `CGImage` with nearest-neighbor scaling. 60fps display timer\n- **Accelerometer**: Dedicated thread reading IOKit HID reports, EMA-smoothed (alpha=0.15)\n- **UI**: SwiftUI toolbar + AppKit `NSView` canvas. Bresenham line interpolation for smooth brush strokes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsevent%2Ftilt-sim-experiment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnsevent%2Ftilt-sim-experiment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsevent%2Ftilt-sim-experiment/lists"}