Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / games / kart / AGENTS.md

AGENTS.md5.0 KiBRenderedCodeRaw

AGENTS.md — games/kart/ (':games:kart')

Scoped supplement. Global rules in root AGENTS.md apply. Stay inside games/kart/ + allowed shared modules. Do not root-scan.

Install: ./install games/kart (release by default).

  • Gradle: :games:kart / dir: games/kart/
  • Package roots present: data, domain, platform, ui
  • Entry files: MainActivity.kt, Route.kt, Navigation.kt
  • Deps: :sdk:controller, :library:e2ee-p2p
  • Metadata: metadata_data/games-kart.md (present)
  • Rust: yes / screenshotTest: yes

Overview

Purpose: 3D kart racer (Sunset Oval) for phones — native Rust engine (Vulkan, with a GLES fallback for devices without Vulkan), kart physics, chase cam, items and AI. Played solo against AI drivers or over LAN: this phone hosts the race and broadcasts it openly on the Wi-Fi, and other phones join as extra drivers from the Games Hub app with no pairing code. Game shape: Route (Lobby / Race / Results) → platform/KartViewModel → domain/ race/input rules + platform/KartHost (:sdk:controller lobby fan-in) → platform/KartNative → src/main/rust/ engine; achievements via :library's AchievementsManager → :sdk:games → hub. Local input (touch + gamepad) is recorded by the ViewModel itself and merged over the host fan-in, so solo races drive even when the LAN host is down. Entry points: Route → MainActivity.kt → Navigation.kt → ui/KartGameScreen.kt → platform/KartViewModel.kt → platform/KartNative.kt / domain/PlaceholderRace.kt. Gotchas:

  • Native Rust: crate kart_engine in src/main/rust/ (engine/physics/track/mesh/items + vulkan/ and gles/ renderers, GLSL kart.vert/kart.frag compiled at runtime by the GLES path). Phone-only: arm64 like every other app; the GLES renderer is the non-Vulkan fallback.
  • platform/KartNative is the sole kart_engine wrapper: every call is gated on KartNative.isAvailable; without the .so the game runs domain/PlaceholderRace — never call native entry points unguarded.
  • Controller dep IS present (:sdk:controller): platform/KartHost broadcasts the open LAN game on _gamepad._tcp (a LanGameBeacon in the TXT record: host name, game, seated/capacity counts, track, open flag), accepts phones and fans ControllerInput into the race loop (domain/GameInputLoop); platform/GamepadDirect handles a locally attached gamepad in MainActivity. PQC identity stays behind lambdas in KartHost — this module never touches the :library:e2ee-p2p native library directly. LAN joins are open: the inner host runs openJoin = true, so any phone that reads the broadcast joins from Games Hub with no pairing code and no approval; the beacon turns closed while racing or full. Solo-vs-bots needs no host at all.
  • Listing images are hand-captured — Layoutlib can't render the Vulkan surface; src/screenshotTest previews cover only the non-surface UI.
  • KartDataStore (data/) is the sole prefs owner (cup pointer + lifetime counters); countdown is in-screen state of Route.Race, not a destination.

Key files

Root — entry + navigation

  • com/vayunmathur/games/kart/MainActivity.kt
  • com/vayunmathur/games/kart/Route.kt
  • com/vayunmathur/games/kart/Navigation.kt

data/ — progress store + models

  • com/vayunmathur/games/kart/data/KartDataStore.kt
  • com/vayunmathur/games/kart/data/KartModels.kt

domain/ — pure race + input rules

  • com/vayunmathur/games/kart/domain/KartRules.kt
  • com/vayunmathur/games/kart/domain/LapTracker.kt
  • com/vayunmathur/games/kart/domain/GameInputLoop.kt
  • com/vayunmathur/games/kart/domain/PlaceholderRace.kt
  • com/vayunmathur/games/kart/domain/RumbleDecider.kt
  • com/vayunmathur/games/kart/domain/TouchControls.kt — held touch state → KartControl / ControllerInput encoding

platform/ — ViewModel, native wrapper, controller host

  • com/vayunmathur/games/kart/platform/KartViewModel.kt
  • com/vayunmathur/games/kart/platform/KartNative.kt — sole guarded kart_engine wrapper
  • com/vayunmathur/games/kart/platform/KartHost.kt — :sdk:controller lobby host
  • com/vayunmathur/games/kart/platform/KartPairingStore.kt
  • com/vayunmathur/games/kart/platform/GamepadDirect.kt
  • com/vayunmathur/games/kart/platform/RacePhase.kt
  • com/vayunmathur/games/kart/platform/KartUiContract.kt
  • com/vayunmathur/games/kart/platform/KartAchievementsManager.kt
  • com/vayunmathur/games/kart/platform/AppBackupAgent.kt

ui/ — race screens + native surface

  • com/vayunmathur/games/kart/ui/KartGameScreen.kt
  • com/vayunmathur/games/kart/ui/KartGamePage.kt
  • com/vayunmathur/games/kart/ui/KartSurfaceView.kt

src/main/rust/ — native engine (kart_engine)

  • src/main/rust/src/lib.rs — JNI entry points
  • src/main/rust/src/engine.rs
  • src/main/rust/src/physics.rs
  • src/main/rust/src/track.rs
  • src/main/rust/src/race.rs
  • src/main/rust/src/items.rs
  • src/main/rust/src/mesh.rs
  • src/main/rust/src/renderer.rs
  • src/main/rust/src/vulkan/mod.rs
  • src/main/rust/src/gles/mod.rs

Verify (this module only)

./gradlew :games:kart:compileDevKotlin
./gradlew :games:kart:lint
./gradlew :games:kart:checkMetadata