From dd91e8700116681c91411dab4682748b7eb390f6 Mon Sep 17 00:00:00 2001 From: Pauljd Date: Mon, 9 Nov 2026 10:31:14 +0000 Subject: [PATCH] Orbiteroids (0.116.0, versionCode 306): Zip clears the sky, Scheme A, five power-ups that switch on when picked up, bot-balanced, zero allocation - Sectors of rocks, tellies, satellites, interference clouds, a rogue beacon and the cosmic anomaly; Drift to find - Hull and shield bars; title, play, sector card (waits for OK) and shared result from Stage B frames 50-53 - OrbiteroidsSimTest: rules, a three-player balance bot on each difficulty, 0 bytes over 10,000 steps - All five Originals now play Co-Authored-By: Claude Opus 5.5 --- android/app/build.gradle.kts | 4 +- .../tv/orbit/classic/arcade/ArcadeGames.kt | 6 +- .../arcade/orbiteroids/OrbiteroidsScreen.kt | 405 ++++++++++++++++++ .../arcade/orbiteroids/OrbiteroidsSim.kt | 316 ++++++++++++++ .../orbit/classic/arcade/ArcadeSessionTest.kt | 5 +- .../tv/orbit/classic/arcade/KidsArcadeTest.kt | 12 +- .../orbit/classic/arcade/TitleTextFitsTest.kt | 15 + .../arcade/orbiteroids/OrbiteroidsSimTest.kt | 128 ++++++ docs/night-shift.md | 13 +- docs/orbiteroids.md | 92 ++++ 10 files changed, 980 insertions(+), 16 deletions(-) create mode 100644 android/app/src/main/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsScreen.kt create mode 100644 android/app/src/main/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsSim.kt create mode 100644 android/app/src/test/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsSimTest.kt create mode 100644 docs/orbiteroids.md diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 0c776cb4..20627e73 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -9,8 +9,8 @@ android { applicationId = "tv.orbit.classic" minSdk = 26 targetSdk = 36 - versionCode = 305 - versionName = "0.115.0-night-shift" + versionCode = 306 + versionName = "0.116.0-orbiteroids" } buildFeatures { compose = true } // The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeGames.kt b/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeGames.kt index b500a503..e745b5fe 100644 --- a/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeGames.kt +++ b/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeGames.kt @@ -91,9 +91,11 @@ internal object ArcadeGames { listOf(Control("◀▶▲▼", "Hop"), Control("OK", "Turn the beam"), BackPause), "Light the mast. No timer and no fail: just Nite Owl's par.") { tv.orbit.classic.arcade.nightshift.NightShiftScreen(it) } + // Playable from 9 November 2026: tv.orbit.classic.arcade.orbiteroids (Scheme A, Paul's choice). val Orbiteroids: ArcadeGame = GameDef("Orbiteroids", "Orbiteroids", "Zip clears the sky", "Fly Zip through the debris and keep the sky clear.", Mascot.Zip, - kidsSuitable = true, original = true, launchable = false, ScoreKind.Points, keepsLevels = false, legacyRecordKey = null, - listOf(Control("◀▶", "Turn"), Control("▲", "Thrust"), Control("OK", "Fire"), BackPause), "Clear each sector, and watch your hull.") + kidsSuitable = true, original = true, launchable = true, ScoreKind.Points, keepsLevels = false, legacyRecordKey = null, + listOf(Control("◀▶▲▼", "Fly that way: Zip aims and fires"), BackPause), "Clear each sector, and watch your hull. Fly through power-ups to switch them on.", + listOf(GameSetting("sounds", "Sound effects"))) { tv.orbit.classic.arcade.orbiteroids.OrbiteroidsScreen(it) } // Classics: the eight Kotlin games, unchanged, each in a thin wrapper. val OrbMan: ArcadeGame = GameDef("OrbMan", "Star Chase", "Maze chase starring Ollie", "Help Ollie clear the stars, and dodge Blaze, Zip, Drift and Luna.", Mascot.Ollie, diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsScreen.kt b/android/app/src/main/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsScreen.kt new file mode 100644 index 00000000..c88ba106 --- /dev/null +++ b/android/app/src/main/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsScreen.kt @@ -0,0 +1,405 @@ +package tv.orbit.classic.arcade.orbiteroids + +import android.view.KeyEvent +import androidx.activity.compose.BackHandler +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.focusable +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.drawWithCache +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Size +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.ImageBitmap +import androidx.compose.ui.graphics.Path +import androidx.compose.ui.graphics.PathEffect +import androidx.compose.ui.graphics.Shadow +import androidx.compose.ui.graphics.StrokeCap +import androidx.compose.ui.graphics.drawscope.DrawScope +import androidx.compose.ui.graphics.drawscope.Stroke +import androidx.compose.ui.graphics.drawscope.rotateRad +import androidx.compose.ui.graphics.drawscope.scale +import androidx.compose.ui.graphics.drawscope.translate +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.input.key.onPreviewKeyEvent +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.IntSize +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.tv.material3.Text +import tv.orbit.classic.Anton +import tv.orbit.classic.Motion +import tv.orbit.classic.OrbCharacter +import tv.orbit.classic.OrbDir +import tv.orbit.classic.R +import tv.orbit.classic.arcade.ArcadeButton +import tv.orbit.classic.arcade.ArcadeColours +import tv.orbit.classic.arcade.ArcadeGameLoop +import tv.orbit.classic.arcade.ArcadeGames +import tv.orbit.classic.arcade.ArcadeKey +import tv.orbit.classic.arcade.ArcadePauseMenu +import tv.orbit.classic.arcade.ArcadePlay +import tv.orbit.classic.arcade.ClassicResult +import tv.orbit.classic.arcade.Control +import tv.orbit.classic.arcade.HowToPlayCard +import tv.orbit.classic.arcade.KeyCap +import tv.orbit.classic.arcade.KeyFooter +import tv.orbit.classic.arcade.Mascot +import tv.orbit.classic.arcade.PauseWhenHidden +import tv.orbit.classic.arcade.RunEnd +import tv.orbit.classic.arcade.RunTracker +import tv.orbit.classic.arcade.SpeechBubble +import tv.orbit.classic.arcade.arcadeKey +import tv.orbit.classic.arcade.backStep +import tv.orbit.classic.arcade.BackStep +import tv.orbit.classic.arcade.onBackKey +import tv.orbit.classic.arcade.previousLine +import tv.orbit.classic.arcade.raiders.Pilot +import tv.orbit.classic.arcade.raiders.pilotFace +import tv.orbit.classic.drawOrbChaser +import tv.orbit.classic.starPath + +/** Orbiteroids' colours (frames 50–53). */ +internal object OColours { + val Space = Color(0xFF0A1236) + val Rock = Color(0xFF8A93A8); val RockDark = Color(0xFF5E6680) + val Hull = Color(0xFF4CD98A); val Shield = Color(0xFF35D6F2); val Empty = Color(0xFF1C2A5A) + val Shot = Color(0xFFFF6FB5) + val Pink = Color(0xFFFF4FA3); val Body = Color(0xFFF1F3FA); val Flame = Color(0xFFFFC23D) + val Beacon = Color(0xFFFF5A4F); val Anomaly = Color(0xFFA77BFF); val Static = Color(0xFFB4BCD6) + fun power(p: OPower) = when (p) { OPower.OrbitShield -> Color(0xFF22C3D8); OPower.MagnetPulse -> Color(0xFFFF5A4F); OPower.SlowOrbit -> Color(0xFF7B7BFF); OPower.SplitBeam -> Color(0xFFFF9F1C); OPower.SignalRepair -> Color(0xFF4CD98A) } +} + +/** The shapes, made once: rocks, the rocket, the satellite and the TV, each at a unit size and scaled when drawn. */ +internal class OrbiteroidsArt(val zip: ImageBitmap) { + val rock = Path().apply { + val pts = floatArrayOf(1f, .82f, .95f, .78f, 1f, .86f, .92f, .8f) + for (k in pts.indices) { val a = k * 6.2832f / pts.size; val r = pts[k]; val x = kotlin.math.sin(a) * r; val y = -kotlin.math.cos(a) * r; if (k == 0) moveTo(x, y) else lineTo(x, y) } + close() + } + val body = Path().apply { moveTo(0f, -16f); cubicTo(7f, -10f, 7f, 4f, 5f, 10f); lineTo(-5f, 10f); cubicTo(-7f, 4f, -7f, -10f, 0f, -16f); close() } + val nose = Path().apply { moveTo(0f, -16f); cubicTo(3.6f, -13f, 5f, -11f, 5.6f, -9f); lineTo(-5.6f, -9f); cubicTo(-5f, -11f, -3.6f, -13f, 0f, -16f); close() } + val finL = Path().apply { moveTo(-5f, 0f); lineTo(-13f, 8f); lineTo(-13f, 11f); lineTo(-5f, 8f); close() } + val finR = Path().apply { moveTo(5f, 0f); lineTo(13f, 8f); lineTo(13f, 11f); lineTo(5f, 8f); close() } + val flame = Path().apply { moveTo(-3f, 10f); quadraticTo(0f, 22f, 3f, 10f); close() } + val hex = Path().apply { for (k in 0..5) { val a = Math.toRadians(60.0 * k + 30); val x = kotlin.math.cos(a).toFloat(); val y = kotlin.math.sin(a).toFloat(); if (k == 0) moveTo(x, y) else lineTo(x, y) }; close() } + val dash = Stroke(1.5f, pathEffect = PathEffect.dashPathEffect(floatArrayOf(5f, 5f))) + val thin = Stroke(1.5f); val mid = Stroke(2f, cap = StrokeCap.Round); val wide = Stroke(3f, cap = StrokeCap.Round) + val zipSize = IntSize(zip.width, zip.height) + + fun DrawScope.ship(x: Float, y: Float, angle: Float, hurt: Boolean, flicker: Float) { + translate(x, y) { + rotateRad(angle, Offset.Zero) { + scale(1.2f, 1.2f, Offset.Zero) { + drawPath(flame, OColours.Flame, alpha = .8f + .2f * flicker) + drawPath(finL, OColours.Pink); drawPath(finR, OColours.Pink) + drawPath(body, if (hurt) Color(0xFFFFB3B3) else OColours.Body) + drawPath(nose, OColours.Pink) + drawCircle(Color(0xFF1B2A4E), 4.6f, Offset(0f, -3f)) + drawImage(zip, IntOffset.Zero, zipSize, IntOffset(-4, -7), IntSize(8, 8)) + } + } + } + } +} + +private enum class OStage { Title, Play, Result } + +/** Orbiteroids' HUD numbers, read once a frame from the sim; Compose only redraws what changed. */ +private class OHud { + var score by mutableIntStateOf(0); var sector by mutableIntStateOf(1); var hull by mutableIntStateOf(5); var shield by mutableIntStateOf(5) + var bounces by mutableIntStateOf(0); var powerSecs by mutableIntStateOf(0); var between by mutableStateOf(false) + var power by mutableStateOf(null); var left by mutableIntStateOf(0) + var frame by mutableIntStateOf(0) + fun read(s: OrbiteroidsSim) { + score = s.score; sector = s.sector; hull = s.hull; shield = s.shield; bounces = s.bounces; between = s.between; left = s.left() + power = s.power ?: s.lastPower?.takeIf { s.lastPowerFor > 0f } + powerSecs = kotlin.math.ceil(s.powerLeft).toInt() + frame++ + } +} + +@Composable +internal fun OrbiteroidsScreen(play: ArcadePlay) { + val gameDef = ArcadeGames.Orbiteroids + val latestPlay by rememberUpdatedState(play) + val calm = Motion.reduce + val density = LocalDensity.current + val art = remember(density) { OrbiteroidsArt(pilotFace(Pilot.Zip, 96, density)) } + val sim = remember { OrbiteroidsSim(play.difficulty) } + val hud = remember { OHud() } + val stepper = remember { tv.orbit.classic.arcade.raiders.FixedStep() } + var stage by remember { mutableStateOf(OStage.Title) } + var paused by remember { mutableStateOf(false) } + var howTo by remember { mutableStateOf(false) } + var soundsOn by remember { mutableStateOf(play.setting("sounds")) } + var bestBefore by remember { mutableIntStateOf(play.best) } + val tracker = remember { RunTracker { end -> latestPlay.onRunEnd(end) } } + fun endRun(finished: Boolean) { tracker.end(RunEnd(sim.score, finished, "Sector ${sim.sector}")) } + DisposableEffect(Unit) { onDispose { endRun(false) } } + LaunchedEffect(Unit) { play.audio.preload(R.raw.power_wide_orbit, R.raw.power_zip_split) } + + fun startRun() { + bestBefore = maxOf(latestPlay.best, bestBefore) + sim.newRun(latestPlay.difficulty, System.nanoTime()) + stepper.reset(); hud.read(sim); tracker.begin(); paused = false; stage = OStage.Play + } + fun pause() { if (stage == OStage.Play && !paused) { paused = true; sim.held = 0; stepper.reset() } } + fun leave() { endRun(sim.over); latestPlay.onLeave() } + + PauseWhenHidden(stage == OStage.Play && !paused) { pause() } + ArcadeGameLoop(running = stage == OStage.Play && !paused) { _, dt -> + val n = stepper.ticks(dt, paused) + var ev = 0 + for (i in 0 until n) { sim.step(); ev = ev or sim.events } + if (ev and (OEvents.POWER or OEvents.DRIFT) != 0) latestPlay.audio.cue(R.raw.power_zip_split, .6f, soundsOn) + if (ev and OEvents.SECTOR != 0) latestPlay.audio.cue(R.raw.power_wide_orbit, .6f, soundsOn) + hud.read(sim) + if (sim.over) { endRun(true); stage = OStage.Result } + } + + val playFocus = remember { FocusRequester() } + LaunchedEffect(stage, paused, hud.between) { if (stage == OStage.Play && !paused && !hud.between) runCatching { playFocus.requestFocus() } } + BackHandler(stage == OStage.Play && !paused) { pause() } + + when (stage) { + OStage.Title -> { + OTitle(art, play.best, play.difficulty.title, refocus = !howTo, onPlay = ::startRun, onHowTo = { howTo = true }, onBack = { latestPlay.onLeave() }) + if (howTo) HowToPlayCard(gameDef, firstRun = false, everyTime = null, onEveryTime = {}, onPlay = { howTo = false }, onBack = { howTo = false }) + } + OStage.Play, OStage.Result -> { + Box(Modifier.fillMaxSize().focusRequester(playFocus).focusable().onPreviewKeyEvent { e -> + if (stage != OStage.Play || paused || hud.between) return@onPreviewKeyEvent false + val n = e.nativeKeyEvent + val key = arcadeKey(n.keyCode) + val down = n.action == KeyEvent.ACTION_DOWN + // Back by context: nothing is ever held in Orbiteroids, so Back (and play/pause) pause. + when (backStep(key, down, n.repeatCount, active = false)) { BackStep.Pause -> { pause(); return@onPreviewKeyEvent true }; BackStep.Cancel -> return@onPreviewKeyEvent true; BackStep.None -> {} } + if (key == ArcadeKey.Back || key == ArcadeKey.PlayPause) return@onPreviewKeyEvent true + // Scheme A: hold an arrow to fly that way (a bit each, up, right, down, left). + val bit = when (key) { ArcadeKey.Up -> 1; ArcadeKey.Right -> 2; ArcadeKey.Down -> 4; ArcadeKey.Left -> 8; else -> 0 } + if (bit == 0) return@onPreviewKeyEvent key == ArcadeKey.Ok + sim.held = if (down) sim.held or bit else sim.held and bit.inv() + true + }) { + OPlay(art, sim, hud, bestBefore, calm, play.reduceFlashing) + if (hud.between && stage == OStage.Play && !paused) SectorCard(hud.sector, onNext = { sim.nextSector(); stepper.reset(); hud.read(sim) }) + if (stage == OStage.Result) ClassicResult(gameDef, "ORBITEROIDS · SECTOR ${sim.sector} REACHED", "SCORE", "%,d".format(sim.score), + newBest = sim.score > bestBefore && sim.score > 0, previous = previousLine(gameDef.scoreKind, bestBefore, gameDef.title), detail = orbiteroidsLine(sim), + cheer = Mascot.Blaze, onAgain = { endRun(sim.over); startRun() }, onBack = ::leave) + } + if (paused && stage == OStage.Play) ArcadePauseMenu(gameDef, "Orbiteroids · Sector ${sim.sector} · ${"%,d".format(sim.score)}", + onResume = { paused = false; stepper.reset() }, onRestart = { endRun(false); startRun() }, onExit = ::leave, + sound = if (soundsOn) "Effects on" else "Effects off", onSound = { soundsOn = !soundsOn; latestPlay.setSetting("sounds", soundsOn) }) + } + } +} + +// ---------- Title (frame 50) ---------- + +@Composable +private fun OTitle(art: OrbiteroidsArt, best: Int, difficulty: String, refocus: Boolean, onPlay: () -> Unit, onHowTo: () -> Unit, onBack: () -> Unit) { + val first = remember { FocusRequester() } + LaunchedEffect(refocus) { if (refocus) runCatching { first.requestFocus() } } + Box(Modifier.fillMaxSize().onBackKey(action = onBack).spaceSky()) { + BackHandler(onBack = onBack) + Canvas(Modifier.fillMaxSize()) { + val w = size.width; val h = size.height + drawCircle(Color(0xFF5865D8), h * .25f, Offset(w * .97f, h * 1.02f)) + drawCircle(Color(0xFF2A1C4E), h * .26f, Offset(w * .34f, h * .55f)) + for ((x, y, r) in listOf(Triple(.09f, .48f, .035f), Triple(.61f, .42f, .03f), Triple(.27f, .74f, .02f), Triple(.55f, .78f, .022f), Triple(.57f, .12f, .02f))) + translate(w * x, h * y) { scale(h * r, h * r, Offset.Zero) { drawPath(art.rock, OColours.Rock) } } + } + // Zip's rocket, large, over its planet. + Canvas(Modifier.fillMaxSize()) { val w = size.width; val h = size.height; translate(w * .34f, h * .55f) { scale(h / 90f, h / 90f, Offset.Zero) { with(art) { ship(0f, 0f, .6f, false, 1f) } } } } + Column(Modifier.fillMaxSize().padding(start = 48.dp, end = 48.dp, top = 24.dp, bottom = 12.dp)) { + Row(Modifier.fillMaxWidth().weight(1f)) { + Column(Modifier.weight(1f)) { + Text("AN ORBIT ARCADE ORIGINAL", Modifier.padding(start = 90.dp), color = ArcadeColours.Muted, fontSize = 13.sp, letterSpacing = 5.sp) + Text("ORBITEROIDS", Modifier.padding(start = 60.dp), color = Color(0xFFF5F7FF), fontFamily = Anton, fontSize = 70.sp, + style = TextStyle(shadow = Shadow(ArcadeColours.Cyan, Offset(5f, 5f), 0f))) + Spacer(Modifier.weight(1f)) + Row { Text("Pilot: Zip", color = ArcadeColours.Ink, fontSize = 14.sp, fontWeight = FontWeight.Bold); Text(" · Controls: Scheme A, fly and it fires for you", color = ArcadeColours.Muted, fontSize = 14.sp) } + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.padding(top = 4.dp)) { + Text("Your best ", color = ArcadeColours.Muted, fontSize = 14.sp); Text(if (best > 0) "%,d".format(best) else "Not played yet", color = ArcadeColours.Ink, fontSize = 14.sp, fontWeight = FontWeight.Bold) + Text(difficulty, Modifier.background(ArcadeColours.Cyan, RoundedCornerShape(10.dp)).padding(horizontal = 8.dp), color = ArcadeColours.Night, fontSize = 12.sp, fontWeight = FontWeight.Bold) + } + } + Column(horizontalAlignment = Alignment.End) { + Row(verticalAlignment = Alignment.CenterVertically) { + SpeechBubble("Rocks ahead.\nLet's fly!") + Canvas(Modifier.size(76.dp)) { drawOrbChaser(center, size.minDimension * .4f, OrbCharacter.Zip, OrbDir.Left, false, false, false, 0f) } + } + Spacer(Modifier.weight(1f)) + Column(Modifier.width(230.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { + ArcadeButton("Play", Modifier.fillMaxWidth().focusRequester(first), icon = "▶", primary = true, height = 34.dp, onClick = onPlay) + ArcadeButton("How to Play", Modifier.fillMaxWidth(), icon = "?", height = 34.dp, onClick = onHowTo) + ArcadeButton("Back to Arcade", Modifier.fillMaxWidth(), icon = "←", height = 34.dp, onClick = onBack) + } + Spacer(Modifier.weight(1f)) + } + } + KeyFooter(listOf(Control("▲▼", "Choose"), Control("OK", "Select"), Control("Back", "Arcade home"))) + } + } +} + +/** Deep space behind everything: a navy field of coloured pinpricks, drawn once in its own layer. */ +private fun Modifier.spaceSky(): Modifier = graphicsLayer().drawWithCache { + val rnd = java.util.Random(55) + val n = 140 + val pts = FloatArray(n * 3) { k -> when (k % 3) { 0 -> rnd.nextFloat() * size.width; 1 -> rnd.nextFloat() * size.height; else -> rnd.nextFloat() } } + val tints = arrayOf(Color.White, Color(0xFFFF4FA3), Color(0xFF35D6F2), Color(0xFFFFDE59)) + onDrawBehind { + drawRect(OColours.Space) + for (i in 0 until n) drawCircle(tints[(pts[i * 3 + 2] * 10).toInt() % 4].copy(alpha = .35f + pts[i * 3 + 2] * .5f), .8f + pts[i * 3 + 2] * 1.4f, Offset(pts[i * 3], pts[i * 3 + 1])) + } +} + +// ---------- Play (frame 51) ---------- + +@Composable +private fun OPlay(art: OrbiteroidsArt, sim: OrbiteroidsSim, hud: OHud, best: Int, calm: Boolean, reduceFlashing: Boolean) { + Box(Modifier.fillMaxSize().spaceSky()) { + Canvas(Modifier.fillMaxSize()) { + hud.frame // a redraw each frame, without recomposing + val k = minOf(size.width / OW, size.height / OH) + val ox = (size.width - OW * k) / 2; val oy = (size.height - OH * k) / 2 + translate(ox, oy) { scale(k, k, Offset.Zero) { drawField(art, sim, calm, reduceFlashing) } } + } + Column(Modifier.fillMaxSize().padding(start = 32.dp, end = 32.dp, top = 22.dp, bottom = 10.dp)) { + Row(Modifier.fillMaxWidth().weight(1f)) { + Column(Modifier.weight(1f)) { + Row(horizontalArrangement = Arrangement.spacedBy(28.dp)) { + Column { OLabel("SCORE"); Text("%,d".format(hud.score), color = ArcadeColours.Ink, fontFamily = Anton, fontSize = 30.sp) } + Column { OLabel("SECTOR"); Text("${hud.sector}", color = ArcadeColours.Ink, fontFamily = Anton, fontSize = 30.sp) } + } + OLabel("BEST"); Text("%,d".format(maxOf(best, hud.score)), color = ArcadeColours.Ink, fontFamily = Anton, fontSize = 24.sp) + Text("${hud.left} to clear", color = ArcadeColours.Muted, fontSize = 14.sp) + } + Column(horizontalAlignment = Alignment.End, verticalArrangement = Arrangement.spacedBy(4.dp)) { + OLabel("HULL"); Bars(hud.hull, OrbiteroidsSim.HULL, OColours.Hull) + OLabel("SHIELD"); Bars(hud.shield, OrbiteroidsSim.SHIELD, OColours.Shield) + if (hud.bounces > 0) Text("Orbit Shield ×${hud.bounces}", color = OColours.power(OPower.OrbitShield), fontSize = 14.sp, fontWeight = FontWeight.SemiBold) + Spacer(Modifier.height(6.dp)) + OLabel("POWER-UP") + val p = hud.power + Canvas(Modifier.size(48.dp)) { if (p != null) badge(art, p, center, size.minDimension * .4f) else drawCircle(OColours.Empty, size.minDimension * .4f, style = Stroke(2f)) } + if (p != null) { + Text(p.title, color = ArcadeColours.Ink, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, textAlign = TextAlign.End) + Text(if (p.seconds > 0f && hud.powerSecs > 0) "${hud.powerSecs} s left" else p.line, color = OColours.power(p), fontSize = 13.sp, textAlign = TextAlign.End) + } else Text("Fly through one", color = ArcadeColours.Muted, fontSize = 13.sp) + } + } + KeyFooter(listOf(Control("◀▶▲▼", "Fly"), Control("Back", "Pause")), note = "Scheme A · aims and fires for you") + } + } +} + +@Composable +private fun OLabel(text: String) = Text(text, color = ArcadeColours.Muted, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 2.sp) + +@Composable +private fun Bars(n: Int, of: Int, colour: Color) = Row(horizontalArrangement = Arrangement.spacedBy(3.dp)) { + for (i in 0 until of) Box(Modifier.size(24.dp, 10.dp).background(if (i < n) colour else OColours.Empty, RoundedCornerShape(3.dp))) +} + +private fun DrawScope.badge(art: OrbiteroidsArt, p: OPower, c: Offset, r: Float) { + translate(c.x, c.y) { scale(r, r, Offset.Zero) { drawPath(art.hex, OColours.power(p)) } } + drawCircle(Color.White.copy(alpha = .9f), r * .3f, c, style = Stroke(r * .12f)) + when (p) { + OPower.SplitBeam -> for (a in floatArrayOf(-.4f, 0f, .4f)) drawLine(Color.White, c + Offset(0f, r * .3f), c + Offset(kotlin.math.sin(a) * r * .55f, -kotlin.math.cos(a) * r * .55f), r * .1f) + OPower.SignalRepair -> { drawLine(Color.White, c - Offset(r * .25f, 0f), c + Offset(r * .25f, 0f), r * .12f); drawLine(Color.White, c - Offset(0f, r * .25f), c + Offset(0f, r * .25f), r * .12f) } + else -> {} + } +} + +/** The field: hazards, Drift, pickups, shots and Zip's rocket, in field units. */ +private fun DrawScope.drawField(art: OrbiteroidsArt, s: OrbiteroidsSim, calm: Boolean, reduceFlashing: Boolean) { + val t = s.clock + for (i in 0 until OrbiteroidsSim.MAX_HZ) { + if (!s.hzOn[i]) continue + val k = s.hzKind[i]; val x = s.hzX[i]; val y = s.hzY[i]; val r = Hz.radius[k] + val hitTint = s.hzTint[i] > 0f + when (k) { + Hz.ROCK_L, Hz.ROCK_M, Hz.ROCK_S -> translate(x, y) { rotateRad(if (calm) 0f else s.hzSpin[i], Offset.Zero) { scale(r, r, Offset.Zero) { + drawPath(art.rock, if (hitTint) Color.White else OColours.Rock); drawCircle(OColours.RockDark, .18f, Offset(.25f, .1f)); drawCircle(OColours.RockDark, .12f, Offset(-.3f, -.3f)) } } } + Hz.TV -> translate(x, y) { rotateRad(if (calm) .3f else s.hzSpin[i] * .5f, Offset.Zero) { + drawRoundRect(if (hitTint) Color.White else OColours.Static, Offset(-r, -r * .7f), Size(r * 2, r * 1.4f), androidx.compose.ui.geometry.CornerRadius(r * .2f), style = art.mid) + drawLine(OColours.Static, Offset(-r * .5f, -r * .3f), Offset(r * .2f, r * .3f), 1.5f); drawLine(OColours.Static, Offset(-r * .2f, -r * .7f), Offset(-r * .5f, -r * 1.1f), 1.5f) } } + Hz.SAT, Hz.SAT_PART -> translate(x, y) { rotateRad(if (calm) 0f else s.hzSpin[i] * .4f, Offset.Zero) { + val w = if (k == Hz.SAT) r else r * .7f + drawRect(Color(0xFF8D95AE), Offset(-w * .35f, -w * .5f), Size(w * .7f, w)) + drawRect(Color(0xFF3F6FD8), Offset(-w * 1.15f, -w * .3f), Size(w * .7f, w * .6f)); if (k == Hz.SAT) drawRect(Color(0xFF3F6FD8), Offset(w * .45f, -w * .3f), Size(w * .7f, w * .6f)) + drawCircle(Color.White, w * .12f, Offset(-w * .12f, -w * .1f)); drawCircle(Color.White, w * .12f, Offset(w * .14f, -w * .1f)) + drawCircle(Color(0xFF14213D), w * .06f, Offset(-w * .12f, -w * .08f)); drawCircle(Color(0xFF14213D), w * .06f, Offset(w * .14f, -w * .08f)) } } + Hz.CLOUD -> { + val a = if (hitTint) .8f else .55f + drawCircle(OColours.Static.copy(alpha = a * .5f), r * .6f, Offset(x - r * .3f, y)); drawCircle(OColours.Static.copy(alpha = a * .5f), r * .7f, Offset(x + r * .2f, y - r * .2f)) + drawCircle(OColours.Static.copy(alpha = a * .5f), r * .55f, Offset(x + r * .45f, y + r * .15f)) + for (l in -2..2) drawLine(Color.White.copy(alpha = .5f), Offset(x - r * .5f, y + l * r * .15f), Offset(x + r * .5f, y + l * r * .15f + (if (calm) 0f else kotlin.math.sin(t * 6f + l) * 2f)), 1f) + } + Hz.BEACON -> { + for (ring in 1..3) drawCircle(OColours.Beacon.copy(alpha = .45f), ring * 40f + (if (calm) 0f else (t * 30f) % 40f), Offset(x, y), style = art.dash) + drawRect(Color(0xFF3A3F55), Offset(x - 5f, y - 4f), Size(10f, 16f)); drawCircle(if (hitTint) Color.White else OColours.Beacon, 6f, Offset(x, y - 6f)) + } + Hz.ANOMALY -> { + drawCircle(OColours.Anomaly.copy(alpha = .18f), r * 2f, Offset(x, y)) + for (arm in 0 until 3) drawArc(OColours.Anomaly, (if (calm) 0f else t * 90f) + arm * 120f, 100f, false, Offset(x - r, y - r), Size(r * 2, r * 2), style = art.wide) + drawCircle(Color(0xFF14213D), r * .25f, Offset(x, y)); drawCircle(OColours.Anomaly, r * .25f, Offset(x, y), style = art.mid) + } + Hz.DRIFT -> drawOrbChaser(Offset(x, y), r, OrbCharacter.Drift, OrbDir.Left, false, false, false, if (calm) 0f else t) + } + } + for (p in 0 until OrbiteroidsSim.MAX_PICKS) if (s.pickOn[p]) badge(art, OPower.entries[s.pickKind[p]], Offset(s.pickX[p], s.pickY[p]), 12f) + for (q in 0 until OrbiteroidsSim.MAX_SHOTS) if (s.shotOn[q]) { + val len = .018f + drawLine(OColours.Shot, Offset(s.shotX[q], s.shotY[q]), Offset(s.shotX[q] - s.shotVx[q] * len, s.shotY[q] - s.shotVy[q] * len), 3f, StrokeCap.Round) + } + // Zip's rocket, inside its shield ring while the shield holds; hurt, it tints (it never flashes the screen). + val hurt = s.hurtFor > 0f && (reduceFlashing || calm || (t * 10).toInt() % 2 == 0) + if (s.shield > 0 || s.bounces > 0) { + val c = if (s.bounces > 0) OColours.power(OPower.OrbitShield) else OColours.Shield + drawCircle(c.copy(alpha = .12f), 30f, Offset(s.shipX, s.shipY)); drawCircle(c.copy(alpha = .6f), 30f, Offset(s.shipX, s.shipY), style = art.thin) + } + with(art) { ship(s.shipX, s.shipY, s.shipAngle, hurt, if (calm) 1f else kotlin.math.sin(t * 30f)) } +} + +// ---------- Between sectors ---------- + +/** A sector cleared: the bonus, and the next sector only when OK is pressed. */ +@Composable +private fun SectorCard(sector: Int, onNext: () -> Unit) { + val first = remember { FocusRequester() } + LaunchedEffect(sector) { runCatching { first.requestFocus() } } + Box(Modifier.fillMaxSize().background(ArcadeColours.Night.copy(alpha = .55f)), contentAlignment = Alignment.Center) { + Column(Modifier.width(380.dp).background(ArcadeColours.PanelDeep, RoundedCornerShape(14.dp)).border(1.dp, ArcadeColours.Line, RoundedCornerShape(14.dp)).padding(20.dp), + horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp)) { + Text("SECTOR $sector CLEAR", color = ArcadeColours.Ink, fontFamily = Anton, fontSize = 32.sp) + Text("+${"%,d".format(1000 * sector)} sector bonus", color = ArcadeColours.Yellow, fontSize = 16.sp, fontWeight = FontWeight.SemiBold) + Text(sectorTeaser(sector + 1), color = ArcadeColours.Muted, fontSize = 14.sp, textAlign = TextAlign.Center) + ArcadeButton("On to sector ${sector + 1}", Modifier.width(240.dp).focusRequester(first), icon = "▶", primary = true, height = 34.dp, onClick = onNext) + } + } +} + +/** What's new in the next sector, when something is. */ +internal fun sectorTeaser(next: Int) = when (next) { + 2 -> "Broken tellies are drifting about. And is that Drift, lost? Fly into him to bring him home." + 3 -> "Satellites ahead: they split in two." + 4 -> "An interference cloud: shoot it away, don't fly through it." + 5 -> "A rogue beacon pulls you in. Five hits to silence it." + 6 -> "A cosmic anomaly: it can't be cleared, so keep clear of it." + else -> "More rocks, a little quicker. The shield mends two bars." +} diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsSim.kt b/android/app/src/main/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsSim.kt new file mode 100644 index 00000000..cb0ac149 --- /dev/null +++ b/android/app/src/main/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsSim.kt @@ -0,0 +1,316 @@ +package tv.orbit.classic.arcade.orbiteroids + +import tv.orbit.classic.arcade.Difficulty +import kotlin.math.atan2 +import kotlin.math.cos +import kotlin.math.sin +import kotlin.math.sqrt + +/** + * Orbiteroids (Stage B frames 50–53, 9 November 2026): Zip clears the sky. Scheme A, Paul's choice: the arrows fly the ship + * that way (it turns for you), and it aims at the nearest hazard and fires on its own. Power-ups switch on when picked up. + * Sector by sector: clear every hazard that can be cleared and the next sector comes. Hull and shield bars, no lives. + * + * Fixed 60 Hz steps over pooled arrays: nothing is made while it runs (checked by OrbiteroidsSimTest). The field is 960 by + * 540 units, wrapping at the edges; the screen scales it. + */ +internal const val OW = 960f +internal const val OH = 540f +internal const val OSTEP = 1f / 60f + +/** The hazards (frame 51), and Drift, lost in a cloud of himself: a friend to find, not to shoot. */ +internal object Hz { + const val ROCK_L = 0; const val ROCK_M = 1; const val ROCK_S = 2; const val TV = 3; const val SAT = 4; const val SAT_PART = 5 + const val CLOUD = 6; const val BEACON = 7; const val ANOMALY = 8; const val DRIFT = 9 + val radius = floatArrayOf(26f, 16f, 9f, 13f, 22f, 12f, 42f, 14f, 30f, 16f) + val hits = intArrayOf(1, 1, 1, 1, 2, 1, 4, 5, 0, 0) + val points = intArrayOf(20, 50, 100, 150, 200, 100, 250, 300, 0, 500) + /** Counts towards clearing a sector (the anomaly can't be cleared, and Drift is a friend). */ + fun clears(kind: Int) = kind != ANOMALY && kind != DRIFT + /** Something the guns aim at. */ + fun target(kind: Int) = kind != ANOMALY && kind != DRIFT +} + +/** Orbiteroids' power-ups (the Stage B sheet): each switches on when Zip flies through it. */ +internal enum class OPower(val title: String, val line: String, val seconds: Float) { + OrbitShield("Orbit Shield", "Bounces off the next 3 hits", 0f), + MagnetPulse("Magnet Pulse", "Pushes rocks back, pulls pickups in", 0f), + SlowOrbit("Slow Orbit", "Everything else slows for 8 s", 8f), + SplitBeam("Split Beam", "Fires three ways for 12 s", 12f), + SignalRepair("Signal Repair", "Mends two hull bars", 0f) +} + +/** What happened this step, for the sounds and the HUD (a bit each). */ +internal object OEvents { const val SHOT = 1; const val HIT = 2; const val CLEARED = 4; const val HURT = 8; const val POWER = 16; const val SECTOR = 32; const val DRIFT = 64; const val OVER = 128 } + +internal class OrbiteroidsSim(var difficulty: Difficulty = Difficulty.Normal, seed: Long = 1) { + private var rnd = java.util.Random(seed) + + // ---------- the ship ---------- + var shipX = OW / 2; var shipY = OH / 2; var shipVx = 0f; var shipVy = 0f + /** Where the nose points, in radians (0 is up). */ + var shipAngle = 0f + var hull = HULL; var shield = SHIELD + /** Orbit Shield's hits left to bounce off. */ + var bounces = 0 + var hurtFor = 0f + private var sinceHurt = 10f + private var shieldTimer = 0f + private var fireIn = 0f + /** The arrows held: a bit each, up, right, down, left. */ + var held = 0 + + // ---------- pools ---------- + val hzKind = IntArray(MAX_HZ); val hzX = FloatArray(MAX_HZ); val hzY = FloatArray(MAX_HZ); val hzVx = FloatArray(MAX_HZ); val hzVy = FloatArray(MAX_HZ) + val hzHits = IntArray(MAX_HZ); val hzSpin = FloatArray(MAX_HZ); val hzOn = BooleanArray(MAX_HZ); val hzTint = FloatArray(MAX_HZ) + val shotX = FloatArray(MAX_SHOTS); val shotY = FloatArray(MAX_SHOTS); val shotVx = FloatArray(MAX_SHOTS); val shotVy = FloatArray(MAX_SHOTS) + val shotLife = FloatArray(MAX_SHOTS); val shotOn = BooleanArray(MAX_SHOTS) + val pickX = FloatArray(MAX_PICKS); val pickY = FloatArray(MAX_PICKS); val pickLife = FloatArray(MAX_PICKS); val pickKind = IntArray(MAX_PICKS); val pickOn = BooleanArray(MAX_PICKS) + + // ---------- the run ---------- + var score = 0; var sector = 1; var clock = 0f + var over = false + /** Between sectors: the "Sector clear" card waits for OK. */ + var between = false + /** The power-up on now (Slow Orbit, Split Beam) and its seconds left. */ + var power: OPower? = null; var powerLeft = 0f + /** The last power-up picked up, for the HUD's badge (Shield, Pulse and Repair act at once). */ + var lastPower: OPower? = null; var lastPowerFor = 0f + // Tallies for the result card (frame 53). + var rocksCleared = 0; var satellitesSplit = 0; var driftFound = 0 + var events = 0 + + /** How fast the sky moves: by difficulty, and a little quicker every sector. */ + val pace get() = when (difficulty) { Difficulty.Gentle -> .75f; Difficulty.Normal -> 1f; Difficulty.Tricky -> 1.25f } * (1f + .07f * (sector - 1)) + + fun newRun(d: Difficulty, seed: Long) { + difficulty = d; rnd = java.util.Random(seed) + shipX = OW / 2; shipY = OH / 2; shipVx = 0f; shipVy = 0f; shipAngle = 0f + hull = HULL; shield = SHIELD; bounces = 0; hurtFor = 0f; sinceHurt = 10f; shieldTimer = 0f; fireIn = 0f; held = 0 + hzOn.fill(false); shotOn.fill(false); pickOn.fill(false) + score = 0; sector = 1; clock = 0f; over = false; between = false; power = null; powerLeft = 0f; lastPower = null; lastPowerFor = 0f + rocksCleared = 0; satellitesSplit = 0; driftFound = 0; events = 0 + startSector() + } + + /** OK on the "Sector clear" card: on to the next. */ + fun nextSector() { if (!between) return; between = false; sector++; startSector() } + + /** A sector's sky: more rocks each time, and a new kind of trouble every sector or so. */ + private fun startSector() { + hzOn.fill(false); shotOn.fill(false) + // The shield mends two bars between sectors (full at the start of a run). + shield = if (sector == 1) SHIELD else minOf(SHIELD, shield + 2); shieldTimer = 0f + val rocks = 3 + sector + sector / 2 + (if (difficulty == Difficulty.Tricky) 1 else 0) - (if (difficulty == Difficulty.Gentle) 1 else 0) + repeat(rocks) { spawnEdge(Hz.ROCK_L) } + if (sector >= 2) repeat(1 + sector / 3) { spawnEdge(Hz.TV) } + if (sector >= 3) repeat(1 + (sector - 3) / 2) { spawnEdge(Hz.SAT) } + if (sector >= 4) spawnEdge(Hz.CLOUD) + if (sector >= 5) spawnEdge(Hz.BEACON) + if (sector >= 6) spawnEdge(Hz.ANOMALY) + if (sector >= 2 && sector % 2 == 0) spawnEdge(Hz.DRIFT) + } + + private fun free(on: BooleanArray): Int { for (i in on.indices) if (!on[i]) return i; return -1 } + + /** A hazard coming in from an edge, well away from the ship, drifting across. */ + private fun spawnEdge(kind: Int) { + var x: Float; var y: Float + do { x = rnd.nextFloat() * OW; y = rnd.nextFloat() * OH } while (dist2(x, y, shipX, shipY) < 220f * 220f) + val speed = when (kind) { Hz.ROCK_L -> 55f; Hz.TV -> 60f; Hz.SAT -> 45f; Hz.CLOUD -> 18f; Hz.BEACON -> 22f; Hz.ANOMALY -> 14f; Hz.DRIFT -> 34f; else -> 60f } * (.7f + rnd.nextFloat() * .6f) + val a = rnd.nextFloat() * 6.2832f + spawn(kind, x, y, cos(a) * speed, sin(a) * speed) + } + + private fun spawn(kind: Int, x: Float, y: Float, vx: Float, vy: Float) { + val i = free(hzOn); if (i < 0) return + hzOn[i] = true; hzKind[i] = kind; hzX[i] = x; hzY[i] = y; hzVx[i] = vx; hzVy[i] = vy; hzHits[i] = Hz.hits[kind]; hzSpin[i] = rnd.nextFloat() * 6.28f; hzTint[i] = 0f + } + + private fun dist2(ax: Float, ay: Float, bx: Float, by: Float): Float { + var dx = ax - bx; var dy = ay - by + if (dx > OW / 2) dx -= OW; if (dx < -OW / 2) dx += OW + if (dy > OH / 2) dy -= OH; if (dy < -OH / 2) dy += OH + return dx * dx + dy * dy + } + private fun wrapX(x: Float) = if (x < 0f) x + OW else if (x >= OW) x - OW else x + private fun wrapY(y: Float) = if (y < 0f) y + OH else if (y >= OH) y - OH else y + + fun step() { + events = 0 + if (over || between) return + val dt = OSTEP + clock += dt + val slow = if (power == OPower.SlowOrbit) .4f else 1f + // ---- the ship: Scheme A, fly the way the arrows say; the nose follows ---- + var ax = 0f; var ay = 0f + if (held and 1 != 0) ay -= 1f; if (held and 4 != 0) ay += 1f; if (held and 8 != 0) ax -= 1f; if (held and 2 != 0) ax += 1f + val len = sqrt(ax * ax + ay * ay) + if (len > 0f) { shipVx += ax / len * THRUST * dt; shipVy += ay / len * THRUST * dt } + val drag = 1f - DRAG * dt + shipVx *= drag; shipVy *= drag + val sp = sqrt(shipVx * shipVx + shipVy * shipVy) + if (sp > MAX_SPEED) { shipVx *= MAX_SPEED / sp; shipVy *= MAX_SPEED / sp } + shipX = wrapX(shipX + shipVx * dt); shipY = wrapY(shipY + shipVy * dt) + if (sp > 12f) { + val want = atan2(shipVx, -shipVy) + var d = want - shipAngle + while (d > Math.PI) d -= (2 * Math.PI).toFloat(); while (d < -Math.PI) d += (2 * Math.PI).toFloat() + shipAngle += d * minOf(1f, 10f * dt) + } + // ---- pulls: the rogue beacon's rings and the anomaly ---- + for (i in 0 until MAX_HZ) { + if (!hzOn[i]) continue + val k = hzKind[i] + if (k == Hz.BEACON || k == Hz.ANOMALY) { + val reach = if (k == Hz.BEACON) 170f else 210f + val d2 = dist2(hzX[i], hzY[i], shipX, shipY) + if (d2 < reach * reach && d2 > 1f) { + var dx = hzX[i] - shipX; var dy = hzY[i] - shipY + if (dx > OW / 2) dx -= OW; if (dx < -OW / 2) dx += OW; if (dy > OH / 2) dy -= OH; if (dy < -OH / 2) dy += OH + val d = sqrt(d2); val pull = (if (k == Hz.BEACON) 150f else 190f) * pace * (1f - d / reach) + shipVx += dx / d * pull * dt; shipVy += dy / d * pull * dt + } + } + } + // ---- the guns: at the nearest hazard in range, on their own ---- + fireIn -= dt + if (fireIn <= 0f) { + var best = -1; var bestD = RANGE * RANGE + for (i in 0 until MAX_HZ) if (hzOn[i] && Hz.target(hzKind[i])) { val d2 = dist2(hzX[i], hzY[i], shipX, shipY); if (d2 < bestD) { bestD = d2; best = i } } + if (best >= 0) { + var dx = hzX[best] - shipX; var dy = hzY[best] - shipY + if (dx > OW / 2) dx -= OW; if (dx < -OW / 2) dx += OW; if (dy > OH / 2) dy -= OH; if (dy < -OH / 2) dy += OH + val a = atan2(dx, -dy) + fire(a) + if (power == OPower.SplitBeam) { fire(a - .22f); fire(a + .22f) } + fireIn = FIRE_GAP; events = events or OEvents.SHOT + } + } + // ---- shots ---- + for (s in 0 until MAX_SHOTS) { + if (!shotOn[s]) continue + shotX[s] = wrapX(shotX[s] + shotVx[s] * dt); shotY[s] = wrapY(shotY[s] + shotVy[s] * dt) + shotLife[s] -= dt + if (shotLife[s] <= 0f) { shotOn[s] = false; continue } + for (i in 0 until MAX_HZ) { + if (!hzOn[i] || !Hz.target(hzKind[i])) continue + val r = Hz.radius[hzKind[i]] + if (dist2(shotX[s], shotY[s], hzX[i], hzY[i]) < r * r) { shotOn[s] = false; hit(i); break } + } + } + // ---- hazards move, and meet the ship ---- + val move = pace * slow + for (i in 0 until MAX_HZ) { + if (!hzOn[i]) continue + hzX[i] = wrapX(hzX[i] + hzVx[i] * move * dt); hzY[i] = wrapY(hzY[i] + hzVy[i] * move * dt) + hzSpin[i] += dt * .8f * move + if (hzTint[i] > 0f) hzTint[i] -= dt + val k = hzKind[i] + val r = Hz.radius[k] + SHIP_R + if (dist2(hzX[i], hzY[i], shipX, shipY) >= r * r) continue + when (k) { + Hz.DRIFT -> { hzOn[i] = false; score += Hz.points[k]; driftFound++; events = events or OEvents.DRIFT } + Hz.CLOUD -> if (hurtFor <= 0f) hurt(.6f) // inside the interference: a bar every so often + else -> if (hurtFor <= 0f) { + hurt(1f) + // Knocked away from what it met. + var dx = shipX - hzX[i]; var dy = shipY - hzY[i] + if (dx > OW / 2) dx -= OW; if (dx < -OW / 2) dx += OW; if (dy > OH / 2) dy -= OH; if (dy < -OH / 2) dy += OH + val d = sqrt(dx * dx + dy * dy).coerceAtLeast(1f) + shipVx = dx / d * 180f; shipVy = dy / d * 180f + if (k != Hz.ANOMALY && k != Hz.BEACON) hit(i) + } + } + } + // ---- pickups: they drift slowly and fade; fly through one and it switches on ---- + for (p in 0 until MAX_PICKS) { + if (!pickOn[p]) continue + pickLife[p] -= dt + if (pickLife[p] <= 0f) { pickOn[p] = false; continue } + if (dist2(pickX[p], pickY[p], shipX, shipY) < (SHIP_R + 14f) * (SHIP_R + 14f)) { pickOn[p] = false; apply(OPower.entries[pickKind[p]]) } + } + if (powerLeft > 0f) { powerLeft -= dt; if (powerLeft <= 0f) { power = null; powerLeft = 0f } } + if (lastPowerFor > 0f) lastPowerFor -= dt + if (hurtFor > 0f) hurtFor -= dt + // The shield is full again at each new sector (startSector); in a sector it only goes down. + sinceHurt += dt + // ---- a sector cleared ---- + var left = 0 + for (i in 0 until MAX_HZ) if (hzOn[i] && Hz.clears(hzKind[i])) left++ + if (left == 0) { score += 1000 * sector; between = true; events = events or OEvents.SECTOR; hzOn.fill(false); shotOn.fill(false); pickOn.fill(false) } + } + + private fun fire(a: Float) { + val s = free(shotOn); if (s < 0) return + shotOn[s] = true; shotX[s] = shipX + sin(a) * SHIP_R; shotY[s] = shipY - cos(a) * SHIP_R + shotVx[s] = sin(a) * SHOT_SPEED; shotVy[s] = -cos(a) * SHOT_SPEED; shotLife[s] = RANGE / SHOT_SPEED + .1f + } + + /** A shot lands: off comes a hit; at none left it's cleared, splitting into smaller pieces where it does. */ + private fun hit(i: Int) { + hzHits[i]--; hzTint[i] = .15f + events = events or OEvents.HIT + if (hzHits[i] > 0) return + val k = hzKind[i]; val x = hzX[i]; val y = hzY[i] + hzOn[i] = false + score += Hz.points[k] + events = events or OEvents.CLEARED + when (k) { + Hz.ROCK_L, Hz.ROCK_M -> { rocksCleared++; val small = if (k == Hz.ROCK_L) Hz.ROCK_M else Hz.ROCK_S; split(small, x, y, if (k == Hz.ROCK_L) 80f else 100f) } + Hz.ROCK_S -> rocksCleared++ + Hz.SAT -> { satellitesSplit++; split(Hz.SAT_PART, x, y, 75f) } + } + // About one in twelve leaves a power-up behind. + if (rnd.nextInt(PICKUP_ONE_IN) == 0) { val p = free(pickOn); if (p >= 0) { pickOn[p] = true; pickX[p] = x; pickY[p] = y; pickLife[p] = 10f; pickKind[p] = rnd.nextInt(OPower.entries.size) } } + } + + private fun split(kind: Int, x: Float, y: Float, speed: Float) { + val a = rnd.nextFloat() * 6.28f + spawn(kind, x, y, cos(a) * speed, sin(a) * speed) + spawn(kind, x, y, -cos(a) * speed, -sin(a) * speed) + } + + /** Losing a bar: the shield first, then the hull; Orbit Shield bounces it off altogether. */ + private fun hurt(safe: Float) { + hurtFor = safe; sinceHurt = 0f; shieldTimer = 0f + if (bounces > 0) { bounces--; return } + events = events or OEvents.HURT + if (shield > 0) shield-- else hull-- + if (hull <= 0) { hull = 0; over = true; events = events or OEvents.OVER } + } + + internal fun apply(p: OPower) { + events = events or OEvents.POWER + lastPower = p; lastPowerFor = 3f + when (p) { + OPower.OrbitShield -> bounces = 3 + OPower.MagnetPulse -> { + for (i in 0 until MAX_HZ) if (hzOn[i]) { + var dx = hzX[i] - shipX; var dy = hzY[i] - shipY + if (dx > OW / 2) dx -= OW; if (dx < -OW / 2) dx += OW; if (dy > OH / 2) dy -= OH; if (dy < -OH / 2) dy += OH + val d = sqrt(dx * dx + dy * dy) + if (d < 240f && d > 1f) { hzVx[i] += dx / d * 140f; hzVy[i] += dy / d * 140f } + } + for (q in 0 until MAX_PICKS) if (pickOn[q]) { pickX[q] = shipX; pickY[q] = shipY } + } + OPower.SlowOrbit, OPower.SplitBeam -> { power = p; powerLeft = p.seconds } + OPower.SignalRepair -> hull = minOf(HULL, hull + 2) + } + } + + /** Hazards still to clear this sector, for the HUD. */ + fun left(): Int { var n = 0; for (i in 0 until MAX_HZ) if (hzOn[i] && Hz.clears(hzKind[i])) n++; return n } + + companion object { + const val MAX_HZ = 64; const val MAX_SHOTS = 48; const val MAX_PICKS = 6 + const val HULL = 5; const val SHIELD = 5 + const val THRUST = 520f; const val DRAG = 1.4f; const val MAX_SPEED = 260f + const val SHIP_R = 13f; const val RANGE = 330f; const val SHOT_SPEED = 620f; const val FIRE_GAP = .32f + const val SHIELD_REGROW = 8f; const val PICKUP_ONE_IN = 12 + } +} + +/** Run end: points, with the sector reached. */ +internal fun orbiteroidsLine(sim: OrbiteroidsSim) = "${sim.rocksCleared} rocks cleared · ${sim.satellitesSplit} satellites split" + + (if (sim.driftFound > 0) " · Drift found ×${sim.driftFound}" else "") + (if (sim.over) " · hull lost in sector ${sim.sector}" else "") diff --git a/android/app/src/test/java/tv/orbit/classic/arcade/ArcadeSessionTest.kt b/android/app/src/test/java/tv/orbit/classic/arcade/ArcadeSessionTest.kt index 8248d6c2..297211cf 100644 --- a/android/app/src/test/java/tv/orbit/classic/arcade/ArcadeSessionTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/arcade/ArcadeSessionTest.kt @@ -83,7 +83,8 @@ class ArcadeSessionTest { assertFalse(resetAllowed(ResetAction.ResetLevelProgress, snake, "p", "p", false)) assertTrue(resetAllowed(ResetAction.ResetLevelProgress, sky, "p", "p", false)) assertTrue(resetAllowed(ResetAction.ResetLevelProgress, hive, "p", "p", false)) - // A coming-soon card has nothing to clear. - assertFalse(resetAllowed(ResetAction.ClearHighScores, ArcadeGames.Orbiteroids, "p", "p", false)) + // A coming-soon card has nothing to clear (every Original plays now, so one is made up here). + val comingSoon = object : ArcadeGame by ArcadeGames.Orbiteroids { override val launchable = false } + assertFalse(resetAllowed(ResetAction.ClearHighScores, comingSoon, "p", "p", false)) } } diff --git a/android/app/src/test/java/tv/orbit/classic/arcade/KidsArcadeTest.kt b/android/app/src/test/java/tv/orbit/classic/arcade/KidsArcadeTest.kt index 3f78edb0..6329670c 100644 --- a/android/app/src/test/java/tv/orbit/classic/arcade/KidsArcadeTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/arcade/KidsArcadeTest.kt @@ -57,29 +57,29 @@ class KidsArcadeTest { } @Test fun pickRecentAndHighScoresFollowTheFilter() { - val chosen = kids.withKidsArcade(KidsArcade.Chosen, setOf("Pairs", "Snake", "Orbiteroids")) + val chosen = kids.withKidsArcade(KidsArcade.Chosen, setOf("Pairs", "Snake", "Retired")) val visible = arcadeVisible(chosen) // Star Chase isn't chosen, so it can't be the pick. assertEquals("Snake", arcadePick(visible)!!.id) assertEquals("OrbMan", arcadePick(arcadeVisible(grown))!!.id) // Recent keeps only games this profile can still see and play. - assertEquals(listOf("Pairs", "Snake"), recentVisible(listOf("Blast", "Pairs", "Orbiteroids", "Snake", "Gone"), visible).map { it.id }) + assertEquals(listOf("Pairs", "Snake"), recentVisible(listOf("Blast", "Pairs", "Retired", "Snake", "Gone"), visible).map { it.id }) assertNull(arcadePick(emptyList())) } @Test fun theFamilyLineSaysWhatKidsReallySee() { // The audit: "On: the games chosen for Kids" promised a choice that didn't exist. assertEquals("Off: no Arcade for Kids", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Off))) - assertEquals("Kids-suitable games: 10 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.KidsSuitable))) - assertEquals("Chosen games: 2 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Chosen, setOf("Pairs", "Sky", "Orbiteroids")))) + assertEquals("Kids-suitable games: 11 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.KidsSuitable))) + assertEquals("Chosen games: 2 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Chosen, setOf("Pairs", "Sky", "Retired")))) assertEquals("Chosen games: none chosen yet, so no Arcade", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Chosen, emptySet()))) } @Test fun everyGameIsDescribed() { assertEquals(ArcadeGames.all.size, ArcadeGames.all.map { it.id }.toSet().size) assertEquals(5, ArcadeGames.originals.size); assertEquals(8, ArcadeGames.classics.size) - // BumbleHive and (Stage D) Orbi-Raiders are the Originals that play; every Classic does. - assertEquals(listOf("OrbiRaiders", "ChannelChaos", "Hive", "NightShift"), ArcadeGames.originals.filter { it.launchable }.map { it.id }) + // All five Originals play now (Orbiteroids, the last, 9 November 2026); every Classic does. + assertEquals(listOf("OrbiRaiders", "ChannelChaos", "Hive", "NightShift", "Orbiteroids"), ArcadeGames.originals.filter { it.launchable }.map { it.id }) assertTrue(ArcadeGames.classics.all { it.launchable }) ArcadeGames.all.forEach { g -> assertTrue(g.id, g.controls.isNotEmpty()); assertTrue(g.id, g.title.isNotBlank()); assertTrue(g.id, g.goal.isNotBlank()) diff --git a/android/app/src/test/java/tv/orbit/classic/arcade/TitleTextFitsTest.kt b/android/app/src/test/java/tv/orbit/classic/arcade/TitleTextFitsTest.kt index 7ded059b..374b4d06 100644 --- a/android/app/src/test/java/tv/orbit/classic/arcade/TitleTextFitsTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/arcade/TitleTextFitsTest.kt @@ -127,4 +127,19 @@ class TitleTextFitsTest { // The level-complete panel's three buttons fit beside Nite Owl. assertTrue(150 + 120 + 140 + 2 * 10 <= 600 - 44 - 110 - 16) } + + @Test fun orbiteroidsWordsFit() { + val anton = Font.createFont(Font.TRUETYPE_FONT, File("src/main/res/font/anton_regular.ttf")) + // The title's name in Anton at 70 sp, from 60 dp in, beside the 230 dp button column. + assertTrue(width(anton.deriveFont(70f), "ORBITEROIDS") <= 960.0 - 96 - 60 - 230) + val sans = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f) + for (label in listOf("▶ Play", "? How to Play", "← Back to Arcade")) assertTrue(label, width(sans, label) <= 230 - 2 * 12 - 4) + // The sector card's button, and each power-up's name in the HUD's right column (about 200 dp). + assertTrue(width(sans, "▶ On to sector 99") <= 240 - 2 * 12 - 4) + val hud = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(15f * 1.3f) + for (p in tv.orbit.classic.arcade.orbiteroids.OPower.entries) assertTrue(p.title, width(hud, p.title) <= 200) + // Every sector teaser fits the card (380 dp less padding) in at most three lines. + val body = Font(Font.SANS_SERIF, Font.PLAIN, 1).deriveFont(14f * 1.3f) + for (n in 2..8) assertTrue("sector $n", width(body, tv.orbit.classic.arcade.orbiteroids.sectorTeaser(n)) <= 3 * (380 - 40)) + } } diff --git a/android/app/src/test/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsSimTest.kt b/android/app/src/test/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsSimTest.kt new file mode 100644 index 00000000..cd10d66a --- /dev/null +++ b/android/app/src/test/java/tv/orbit/classic/arcade/orbiteroids/OrbiteroidsSimTest.kt @@ -0,0 +1,128 @@ +package tv.orbit.classic.arcade.orbiteroids + +import org.junit.Assert.* +import org.junit.Test +import tv.orbit.classic.arcade.Difficulty +import kotlin.math.sqrt + +/** Orbiteroids' rules, a balance bot on each difficulty, and no allocation while it runs. */ +class OrbiteroidsSimTest { + private fun fresh(d: Difficulty = Difficulty.Normal, seed: Long = 1) = OrbiteroidsSim(d).also { it.newRun(d, seed) } + + /** + * A plain pilot with a reaction delay: dodges whatever is close and coming, otherwise closes in on the nearest thing to + * shoot (Zip's guns reach 330), and goes for pickups and Drift. + */ + private fun bot(s: OrbiteroidsSim, reaction: Int, random: java.util.Random) { + if (s.between) { s.nextSector(); return } + if (random.nextInt(reaction) != 0) return + var ax = 0f; var ay = 0f; var threat = false + var nearest = -1; var nearD = Float.MAX_VALUE + for (i in 0 until OrbiteroidsSim.MAX_HZ) { + if (!s.hzOn[i]) continue + var dx = s.hzX[i] - s.shipX; var dy = s.hzY[i] - s.shipY + if (dx > OW / 2) dx -= OW; if (dx < -OW / 2) dx += OW; if (dy > OH / 2) dy -= OH; if (dy < -OH / 2) dy += OH + val d = sqrt(dx * dx + dy * dy).coerceAtLeast(1f) + if (s.hzKind[i] == Hz.DRIFT) { ax += dx / d; ay += dy / d; continue } + val danger = Hz.radius[s.hzKind[i]] + (if (s.hzKind[i] == Hz.ANOMALY || s.hzKind[i] == Hz.BEACON) 160f else 70f) + if (d < danger) { ax -= dx / d * 2f; ay -= dy / d * 2f; threat = true } + if (Hz.target(s.hzKind[i]) && d < nearD) { nearD = d; nearest = i } + } + if (!threat && nearest >= 0 && nearD > 250f) { + var dx = s.hzX[nearest] - s.shipX; var dy = s.hzY[nearest] - s.shipY + if (dx > OW / 2) dx -= OW; if (dx < -OW / 2) dx += OW; if (dy > OH / 2) dy -= OH; if (dy < -OH / 2) dy += OH + ax += dx / nearD; ay += dy / nearD + } + for (p in 0 until OrbiteroidsSim.MAX_PICKS) if (s.pickOn[p]) { ax += (s.pickX[p] - s.shipX) * .004f; ay += (s.pickY[p] - s.shipY) * .004f } + var held = 0 + if (ay < -.3f) held = held or 1; if (ay > .3f) held = held or 4; if (ax > .3f) held = held or 2; if (ax < -.3f) held = held or 8 + s.held = held + } + + private fun playBot(d: Difficulty, seed: Long, reaction: Int, maxMinutes: Int = 12): OrbiteroidsSim { + val s = fresh(d, seed); val r = java.util.Random(seed * 7) + var ticks = 0 + while (!s.over && ticks < maxMinutes * 3600) { bot(s, reaction, r); s.step(); ticks++ } + return s + } + + @Test fun aSectorStartsWithRocksAndClearsWhenTheyreGone() { + val s = fresh() + assertTrue(s.left() >= 4); assertEquals(1, s.sector) + // Clear everything by hand: the sector is cleared, the bonus paid, and the card waits for OK. + for (i in 0 until OrbiteroidsSim.MAX_HZ) s.hzOn[i] = false + s.step() + assertTrue(s.between); assertEquals(1000, s.score) + s.step(); assertTrue(s.between) // nothing moves while the card is up + s.nextSector(); assertFalse(s.between); assertEquals(2, s.sector); assertTrue(s.left() > 0) + } + + @Test fun aBigRockSplitsInTwoAndTheGunsAimOnTheirOwn() { + val s = fresh() + for (i in 0 until OrbiteroidsSim.MAX_HZ) s.hzOn[i] = false + s.hzOn[0] = true; s.hzKind[0] = Hz.ROCK_L; s.hzX[0] = s.shipX; s.hzY[0] = s.shipY - 150f; s.hzVx[0] = 0f; s.hzVy[0] = 0f; s.hzHits[0] = 1 + repeat(60) { s.step() } + assertTrue(s.rocksCleared >= 1); assertTrue(s.score >= Hz.points[Hz.ROCK_L]) + } + + @Test fun shieldTakesHitsBeforeTheHullAndOrbitShieldBouncesThem() { + val s = fresh() + for (i in 0 until OrbiteroidsSim.MAX_HZ) s.hzOn[i] = false + // A far-off cloud keeps the sector open (else it would count as cleared); the anomaly can't be shot, so it reaches the ship. + s.hzOn[2] = true; s.hzKind[2] = Hz.CLOUD; s.hzX[2] = 10f; s.hzY[2] = 10f; s.hzVx[2] = 0f; s.hzVy[2] = 0f; s.hzHits[2] = 99 + fun rockOnShip() { s.hzOn[1] = true; s.hzKind[1] = Hz.ANOMALY; s.hzX[1] = s.shipX; s.hzY[1] = s.shipY; s.hzVx[1] = 0f; s.hzVy[1] = 0f; s.hzHits[1] = 1; s.hurtFor = 0f } + s.apply(OPower.OrbitShield); assertEquals(3, s.bounces) + rockOnShip(); s.step(); assertEquals(2, s.bounces); assertEquals(OrbiteroidsSim.SHIELD, s.shield) + s.bounces = 0; rockOnShip(); s.step(); assertEquals(OrbiteroidsSim.SHIELD - 1, s.shield); assertEquals(OrbiteroidsSim.HULL, s.hull) + s.shield = 0; rockOnShip(); s.step(); assertEquals(OrbiteroidsSim.HULL - 1, s.hull) + s.apply(OPower.SignalRepair); assertEquals(OrbiteroidsSim.HULL, s.hull) + s.apply(OPower.SplitBeam); assertEquals(OPower.SplitBeam, s.power) + } + + @Test fun findingDriftIsABonusNotAHit() { + val s = fresh() + s.hzOn[63] = true; s.hzKind[63] = Hz.DRIFT; s.hzX[63] = s.shipX; s.hzY[63] = s.shipY; s.hzVx[63] = 0f; s.hzVy[63] = 0f + val hull = s.hull; val shield = s.shield + s.step() + assertEquals(1, s.driftFound); assertEquals(hull, s.hull); assertEquals(shield, s.shield); assertFalse(s.hzOn[63]) + } + + @Test fun aBotsRunsAreBalancedAcrossTheDifficulties() { + // Three players: a young one deciding every half second, an ordinary one every third, a sharp one every sixth. + val players = listOf("young" to 30, "ordinary" to 18, "sharp" to 10) + val table = HashMap, Double>(); var over = 0 + for (d in Difficulty.entries) for ((who, reaction) in players) { + val runs = (1..10).map { playBot(d, it.toLong(), reaction) } + table[d to who] = runs.map { it.sector }.average(); over += runs.count { it.over } + println("Orbiteroids bot, $who on $d: sector ${"%.1f".format(table[d to who])}, score ${runs.map { it.score }.average().toInt()}, game over ${runs.count { it.over }} of 10") + } + // Over all three players, Gentle goes furthest and Tricky least, and Tricky ends more runs. + val avg = Difficulty.entries.associateWith { d -> players.map { (who, _) -> table[d to who]!! }.average() } + assertTrue("$avg", avg[Difficulty.Gentle]!! > avg[Difficulty.Normal]!! && avg[Difficulty.Normal]!! > avg[Difficulty.Tricky]!!) + // A young player on Gentle gets well past the first sector; nobody clears the sky for ever on Tricky. + assertTrue(table[Difficulty.Gentle to "young"]!! >= 3.0) + assertTrue(table[Difficulty.Tricky to "sharp"]!! < 30.0) + // Runs end: this is an arcade game, not a screensaver. + assertTrue(over > 0) + } + + @Test fun nothingIsAllocatedWhileItRuns() { + val s = fresh(Difficulty.Normal, 9); val r = java.util.Random(1) + repeat(2_000) { bot(s, 3, r); s.step() } // warm up + val mx = java.lang.management.ManagementFactory.getThreadMXBean() as com.sun.management.ThreadMXBean + val before = mx.getThreadAllocatedBytes(Thread.currentThread().id) + var n = 0 + while (n < 10_000) { if (s.over) s.newRun(Difficulty.Normal, n.toLong()); if (s.between) s.nextSector(); s.held = (n / 30) % 16; s.step(); n++ } + val bytes = mx.getThreadAllocatedBytes(Thread.currentThread().id) - before + println("Orbiteroids: 10,000 ticks allocated $bytes bytes") + assertTrue("allocated $bytes", bytes < 8 * 1024) + } + + @Test fun eachSectorBringsItsOwnTrouble() { + assertTrue(sectorTeaser(4).contains("cloud")); assertTrue(sectorTeaser(6).contains("anomaly")) + val s = fresh() + s.sector = 6; for (i in 0 until OrbiteroidsSim.MAX_HZ) s.hzOn[i] = false; s.step(); s.nextSector() + val kinds = (0 until OrbiteroidsSim.MAX_HZ).filter { s.hzOn[it] }.map { s.hzKind[it] }.toSet() + assertTrue(kinds.containsAll(listOf(Hz.ROCK_L, Hz.TV, Hz.SAT, Hz.CLOUD, Hz.BEACON, Hz.ANOMALY))) + } +} diff --git a/docs/night-shift.md b/docs/night-shift.md index 93c4db65..8dc6b271 100644 --- a/docs/night-shift.md +++ b/docs/night-shift.md @@ -71,11 +71,16 @@ A calm puzzle for the late shift: no timer, no fail. - A bot plays each through the game's own moves (hop to each piece the light needs, turn it right, hop until the clouds clear) and lights every mast within Owl's par on Gentle, Normal and Tricky. -## Not in this first build: Paul's call +## Power-ups (added in 0.116.0) + +From the pause menu's **Power-ups** line, so no Menu key is needed: one of each a level (Sleepy Time only where there are +clouds), optional, never counted as moves, so par and stars work without them. As the Stage B power-up sheet has them: +**Moonbeam** shows the route softly, **Sleepy Time** naps the clouds for 6 hops, **Star Magnet** pulls the light on (the +nearest piece it needs turns right), **Night Vision** shows the pieces still turned the wrong way. The play screen lists +what's left. + +## Not in this build: Paul's call -- **Power-ups** (frame 41's Moonbeam, Sleepy Time, Star Magnet and Night Vision, "Menu: use one") are left out. The - design uses the Menu key, which the Xiaomi remote doesn't seem to have; that's what broke Patience's Send home. They need - another way to be chosen (the pause menu, or a long press of OK) before they go in. - **Settings** on the title is left out; the Arcade's own Settings cover difficulty and accessibility. - **The right lid lifting** on frame 42 is drawn as Nite Owl's lids part-lifted and a sideways glance. His art is unchanged, and it has no single-lid option. diff --git a/docs/orbiteroids.md b/docs/orbiteroids.md new file mode 100644 index 00000000..f49677ee --- /dev/null +++ b/docs/orbiteroids.md @@ -0,0 +1,92 @@ +# Orbiteroids (0.116.0, versionCode 306, 9 November 2026) + +Branch `classics-modes`, on top of 0.115.0. The last of the five Orbit Originals, from the approved Stage B frames 50 to 53 +(`orbit-tv/design/arcade/stage-b/orbiteroids.figcraft`) and the power-up sheet. Not installed; nothing seen running. + +## The game + +- **Zip pilots** the rocket (white, pink fins, Zip in the porthole: the cast's own art, as in Orbi-Raiders). +- **Scheme A, Paul's choice:** hold an arrow and the ship flies that way, turning for you. It aims at the nearest hazard + and fires on its own. Back pauses. Scheme B (rotate and thrust) isn't built. +- **Sectors:** clear every hazard that can be cleared and the sector's done. A card shows the bonus (1,000 × the sector) + and what's new next, and waits for OK. +- **The hazards (frame 51), as they arrive:** + +| Sector | Arrives | +|---|---| +| 1 | Rocks: big ones split in two, and those again | +| 2 | Broken tellies drifting about | +| 3 | Satellites, which split in two | +| 4 | Interference clouds (four hits; inside one, a bar goes now and then) | +| 5 | A rogue beacon whose rings pull you in (five hits) | +| 6 | The cosmic anomaly: it pulls, it hurts, and it can't be cleared | + + **Drift**, lost as a cloud of himself, turns up every other sector from the second: the guns leave him alone, and flying + into him finds him (+500). +- **Hull and shield:** five bars each, the shield first. The shield mends two bars between sectors. No lives: the run ends + when the hull's gone. +- **Power-ups** (the sheet's five, about one hazard in twelve leaves one behind): they switch on when Zip flies through + them (scheme A, as Paul chose). + - **Orbit Shield:** bounces off the next 3 hits. + - **Magnet Pulse:** pushes rocks back and pulls pickups in. + - **Slow Orbit:** everything else slows for 8 s. + - **Split Beam:** fires three ways for 12 s. + - **Signal Repair:** mends two hull bars. +- **Difficulty:** Gentle moves the sky at ¾ pace with one rock fewer; Tricky at 1¼ with one more. Every sector is a + little quicker (7%). +- **Reduce motion:** the rocks don't spin, and the anomaly, the beacon's rings and the cloud's static hold still. +- **Reduce flashing:** a hit tints the ship rather than flickering it. Nothing flashes the screen. + +## Screens + +- **Title (50):** + - The ORBITEROIDS logo, Zip's rocket over its planet, and Zip saying "Rocks ahead. Let's fly!". + - Play, How to Play, Back to Arcade. + - "Pilot: Zip · Controls: Scheme A", your best, and the difficulty. + - One mode, so no Mode button. +- **Play (51):** score, sector and best on the left (with how many are left to clear); hull, shield and the power-up badge + on the right; the footer says "Scheme A · aims and fires for you". +- **Sector clear:** waits for OK. +- **Result (53):** + - The shared result: ORBITEROIDS · SECTOR n REACHED, NEW BEST and the score. + - "86 rocks cleared · 12 satellites split · hull lost in sector 4". + - Zip and Blaze cheering. +- **Pause:** the shared menu, with the Sound line. + +## Saves + +High Scores per profile, as points ("Sector n" on each run), and its Sound setting. It's new since profiles, so there's no +Household record. Kids-suitable. + +## Checks + +- **`OrbiteroidsSimTest`** (8 tests): + - Sectors clear and the card waits. + - Rocks split and the guns aim themselves. + - The shield before the hull, and Orbit Shield's bounces and the other power-ups. + - Drift's a bonus, not a hit. + - Each sector brings its trouble. + - **0 bytes allocated over 10,000 steps** (pooled arrays; the screen keeps no per-frame objects either: the shapes and + Zip's face are made once). +- **The balance bot**: three players deciding every ½, ⅓ and ⅙ second, ten runs each, at most 12 minutes: + +| | young | ordinary | sharp | +|---|---|---|---| +| Gentle | sector 9.9, all 10 runs ended | 11.6, 8 ended | 11.2, 0 ended | +| Normal | 8.3, 10 ended | 8.6, 9 ended | 10.3, 8 ended | +| Tricky | 7.0, 10 ended | 9.1, 10 ended | 7.7, 7 ended | + + On average Gentle goes furthest and Tricky least; runs end. (The bot dodges and closes in; a person who sits still + and lets the guns work does surprisingly well, so the first tuning had to get busier.) +- **Kids and session tests** updated: all five Originals play now, there are 11 Kids-suitable games, and the coming-soon + check uses a made-up card. +- **Fit checks:** the logo, buttons, sector card and power-up names fit at the largest font scale. +- **Unit tests:** 1,053 run, 24 skipped, 0 failed. +- **Lint:** 0 errors, 87 warnings (none new). +- **Release APK:** 48,170,591 bytes (+49,144 on 0.115.0, which this build also carries Night Shift's power-ups on top of). + +## Not built + +- Scheme B (rotate and thrust). +- The title's High Scores and Settings buttons from frame 50: the Arcade has both pages. +- No new sounds: pickups and sector clears use the existing power-up cues.