|
|
|
@@ -1,6 +1,5 @@
|
|
|
|
|
package tv.orbit.classic.arcade.rush
|
|
|
|
|
|
|
|
|
|
import tv.orbit.classic.arcade.Sfx
|
|
|
|
|
import android.view.KeyEvent
|
|
|
|
|
import androidx.activity.compose.BackHandler
|
|
|
|
|
import androidx.compose.foundation.Canvas
|
|
|
|
@@ -14,23 +13,36 @@ 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.CornerRadius
|
|
|
|
|
import androidx.compose.ui.geometry.Offset
|
|
|
|
|
import androidx.compose.ui.geometry.Size
|
|
|
|
|
import androidx.compose.ui.graphics.Brush
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
import androidx.compose.ui.graphics.ImageBitmap
|
|
|
|
|
import androidx.compose.ui.graphics.Path
|
|
|
|
|
import androidx.compose.ui.graphics.StrokeCap
|
|
|
|
|
import androidx.compose.ui.graphics.drawscope.CanvasDrawScope
|
|
|
|
|
import androidx.compose.ui.graphics.drawscope.DrawScope
|
|
|
|
|
import androidx.compose.ui.graphics.drawscope.Stroke
|
|
|
|
|
import androidx.compose.ui.graphics.drawscope.scale
|
|
|
|
|
import androidx.compose.ui.graphics.drawscope.translate
|
|
|
|
|
import androidx.compose.ui.graphics.graphicsLayer
|
|
|
|
|
import androidx.compose.ui.platform.LocalDensity
|
|
|
|
|
import androidx.compose.ui.text.TextStyle
|
|
|
|
|
import androidx.compose.ui.text.drawText
|
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
|
import androidx.compose.ui.text.rememberTextMeasurer
|
|
|
|
|
import androidx.compose.ui.unit.Density
|
|
|
|
|
import androidx.compose.ui.unit.IntOffset
|
|
|
|
|
import androidx.compose.ui.unit.IntSize
|
|
|
|
|
import androidx.compose.ui.unit.LayoutDirection
|
|
|
|
|
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.ArcadeBackdrop
|
|
|
|
|
import tv.orbit.classic.Motion
|
|
|
|
|
import tv.orbit.classic.OrbCharacter
|
|
|
|
|
import tv.orbit.classic.OrbDir
|
|
|
|
|
import tv.orbit.classic.arcade.ArcadeColours
|
|
|
|
|
import tv.orbit.classic.arcade.ArcadeGameLoop
|
|
|
|
|
import tv.orbit.classic.arcade.ArcadeGames
|
|
|
|
@@ -40,40 +52,135 @@ import tv.orbit.classic.arcade.ArcadePlay
|
|
|
|
|
import tv.orbit.classic.arcade.ClassicResult
|
|
|
|
|
import tv.orbit.classic.arcade.ClassicTitle
|
|
|
|
|
import tv.orbit.classic.arcade.Control
|
|
|
|
|
import tv.orbit.classic.arcade.Difficulty
|
|
|
|
|
import tv.orbit.classic.arcade.HowToPlayCard
|
|
|
|
|
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.Sfx
|
|
|
|
|
import tv.orbit.classic.arcade.gameKeys
|
|
|
|
|
import tv.orbit.classic.arcade.orbiteroids.OrbiteroidsArt
|
|
|
|
|
import tv.orbit.classic.arcade.previousLine
|
|
|
|
|
import tv.orbit.classic.arcade.raiders.FixedStep
|
|
|
|
|
import tv.orbit.classic.arcade.raiders.Pilot
|
|
|
|
|
import tv.orbit.classic.arcade.raiders.pilotFace
|
|
|
|
|
import tv.orbit.classic.ArcadeBackdrop
|
|
|
|
|
import tv.orbit.classic.starPath
|
|
|
|
|
import tv.orbit.classic.arcade.raiders.StoryArt
|
|
|
|
|
import tv.orbit.classic.drawOrbChaser
|
|
|
|
|
import tv.orbit.classic.drawOrbMascot
|
|
|
|
|
|
|
|
|
|
/** Orbit Rush's colours: plain shapes first (the prototype), each hazard its own colour and shape, unlike Orbiteroids'. */
|
|
|
|
|
/**
|
|
|
|
|
* Orbit Rush's look. The warnings never change colour from region to region (red, change lane; yellow, rise; cyan, dive),
|
|
|
|
|
* so the moves stay readable; everything else takes its region's colours.
|
|
|
|
|
*/
|
|
|
|
|
internal object RColours {
|
|
|
|
|
val Rock = Color(0xFFC2662D); val RockDark = Color(0xFF7A3A16)
|
|
|
|
|
val Low = Color(0xFF3F6FD8); val Panel = Color(0xFF9EC1FF)
|
|
|
|
|
val Tall = Color(0xFFE040A0)
|
|
|
|
|
val Star = Color(0xFFFFDE59)
|
|
|
|
|
val Shield = Color(0xFF22C3D8)
|
|
|
|
|
val Track = Color(0xFF16245A); val Edge = Color(0xFF3D63B8)
|
|
|
|
|
val Magnet = Color(0xFFFF6B9A)
|
|
|
|
|
val Double = Color(0xFFFFB13D)
|
|
|
|
|
val Portal = Color(0xFFB57CFF)
|
|
|
|
|
/** The warning on a lane before each hazard: red means change lane, yellow means rise, cyan means dive. */
|
|
|
|
|
fun warn(kind: Int) = when (kind) { RKind.ROCK -> Color(0xFFFF6B6B); RKind.LOW -> Color(0xFFFFDE59); else -> Color(0xFF35D6F2) }
|
|
|
|
|
fun power(p: Int) = when (p) { RPower.SHIELD -> Shield; RPower.MAGNET -> Magnet; else -> Double }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** One region's colours: its sky, its track, and its three hazards (each still lit by its warning colour). */
|
|
|
|
|
internal class RegionLook(val skyTop: Color, val skyLow: Color, val ground: Color, val track: Color, val edge: Color,
|
|
|
|
|
val block: Color, val blockDark: Color, val low: Color, val lowLight: Color, val tall: Color)
|
|
|
|
|
|
|
|
|
|
internal val RegionLooks = arrayOf(
|
|
|
|
|
// Asteroid Alley: deep blue, brown tumbling rocks.
|
|
|
|
|
RegionLook(Color(0xFF040A1E), Color(0xFF0E1A48), Color(0xFF060C24), Color(0xFF16245A), Color(0xFF3D63B8),
|
|
|
|
|
Color(0xFFC2662D), Color(0xFF7A3A16), Color(0xFF3F6FD8), Color(0xFF9EC1FF), Color(0xFFE040A0)),
|
|
|
|
|
// Broadcast Boulevard: teal night, broken TV screens, satellite arrays, signal gates.
|
|
|
|
|
RegionLook(Color(0xFF031A22), Color(0xFF0B3A4A), Color(0xFF041419), Color(0xFF0E3340), Color(0xFF2FA5B8),
|
|
|
|
|
Color(0xFF2A2F45), Color(0xFF151827), Color(0xFF8D95AE), Color(0xFFE6EEFF), Color(0xFFFF8A3D)),
|
|
|
|
|
// The Static Zone: grey-violet, rogue pixels and interference.
|
|
|
|
|
RegionLook(Color(0xFF14121E), Color(0xFF2B2740), Color(0xFF0D0B16), Color(0xFF26223A), Color(0xFF8D86B8),
|
|
|
|
|
Color(0xFF6CE0A0), Color(0xFF2F7A55), Color(0xFFB9B4D6), Color(0xFFFFFFFF), Color(0xFFFF4FA3)),
|
|
|
|
|
// The Forbidden Frequency: deep purple, dark crystals, the 999 portal.
|
|
|
|
|
RegionLook(Color(0xFF12041F), Color(0xFF2E0B4A), Color(0xFF0A0214), Color(0xFF240A3D), Color(0xFFB57CFF),
|
|
|
|
|
Color(0xFF6A3DC7), Color(0xFF2C1460), Color(0xFF8F5BE0), Color(0xFFE2CCFF), Color(0xFF35D6F2)),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
/** The secret route behind the 999 portal: Orbi-Fax's teletext colours. */
|
|
|
|
|
private val SecretLook = RegionLook(Color(0xFF000000), Color(0xFF00005A), Color(0xFF000014), Color(0xFF0000AA), Color(0xFFFFFF00),
|
|
|
|
|
Color.Black, Color.Black, Color.Black, Color.Black, Color.Black)
|
|
|
|
|
|
|
|
|
|
private enum class RStage { Title, Play, Result }
|
|
|
|
|
|
|
|
|
|
/** HUD numbers, read once a frame; Compose redraws only what changed. */
|
|
|
|
|
private class RHud {
|
|
|
|
|
var score by mutableIntStateOf(0); var hull by mutableIntStateOf(RushSim.HULL); var stars by mutableIntStateOf(0)
|
|
|
|
|
var shieldHeld by mutableStateOf(false); var shieldSecs by mutableIntStateOf(0); var frame by mutableIntStateOf(0)
|
|
|
|
|
fun read(s: RushSim) { score = s.score; hull = s.hull; stars = s.stars; shieldHeld = s.shieldHeld; shieldSecs = kotlin.math.ceil(s.shieldFor).toInt(); frame++ }
|
|
|
|
|
var score by mutableIntStateOf(0); var hull by mutableIntStateOf(RushSim.HULL); var hullMax by mutableIntStateOf(RushSim.HULL); var stars by mutableIntStateOf(0)
|
|
|
|
|
var held by mutableIntStateOf(RPower.NONE); var active by mutableIntStateOf(RPower.NONE); var activeSecs by mutableIntStateOf(0)
|
|
|
|
|
var charge by mutableIntStateOf(0); var metres by mutableIntStateOf(0); var region by mutableIntStateOf(0); var secret by mutableStateOf(false)
|
|
|
|
|
var frame by mutableIntStateOf(0)
|
|
|
|
|
fun read(s: RushSim) {
|
|
|
|
|
score = s.score; hull = s.hull; hullMax = s.hullMax; stars = s.stars; held = s.held; active = if (s.activeFor > 0f) s.active else RPower.NONE
|
|
|
|
|
activeSecs = kotlin.math.ceil(s.activeFor).toInt(); charge = (s.charge * 10).toInt(); metres = s.distance.toInt() / 10 * 10; region = s.region
|
|
|
|
|
secret = s.secretFor > 0f; frame++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** The cast's faces, drawn once into bitmaps from the cast library. Only Ollie has a mouth, as everywhere in Orbit. */
|
|
|
|
|
internal fun rushFace(p: RPilot, px: Int, density: Density): ImageBitmap {
|
|
|
|
|
val image = ImageBitmap(px, px)
|
|
|
|
|
CanvasDrawScope().draw(density, LayoutDirection.Ltr, androidx.compose.ui.graphics.Canvas(image), Size(px.toFloat(), px.toFloat())) {
|
|
|
|
|
val c = Offset(px / 2f, px / 2f); val r = px * .33f
|
|
|
|
|
when (p) {
|
|
|
|
|
RPilot.Ollie -> drawOrbMascot(c, r, OrbDir.Up)
|
|
|
|
|
RPilot.Blaze -> drawOrbChaser(c, r * 1.1f, OrbCharacter.Blaze, OrbDir.Up, false, false, false, 0f)
|
|
|
|
|
RPilot.Zip -> drawOrbChaser(c, r * 1.1f, OrbCharacter.Zip, OrbDir.Up, false, false, false, 0f)
|
|
|
|
|
RPilot.Drift -> drawOrbChaser(c, r * 1.1f, OrbCharacter.Drift, OrbDir.Up, false, false, false, 0f)
|
|
|
|
|
RPilot.Luna -> drawOrbChaser(c, r * 1.1f, OrbCharacter.Luna, OrbDir.Up, false, false, false, 0f)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return image
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Each pilot's colour: the rocket's fins and the ability's glow. Ollie's is Orbit's yellow. */
|
|
|
|
|
internal fun pilotColour(p: RPilot) = when (p) {
|
|
|
|
|
RPilot.Ollie -> Color(0xFFFFD23F); RPilot.Blaze -> OrbCharacter.Blaze.colour; RPilot.Zip -> OrbCharacter.Zip.colour
|
|
|
|
|
RPilot.Drift -> OrbCharacter.Drift.colour; RPilot.Luna -> OrbCharacter.Luna.colour
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Everything drawn that's made once: the rocket's shapes, the faces, the 999 sign, reused every frame. */
|
|
|
|
|
internal class RushArt(val faces: Array<ImageBitmap>, val portalSign: androidx.compose.ui.text.TextLayoutResult) {
|
|
|
|
|
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 bigFlame = Path().apply { moveTo(-4f, 10f); quadraticTo(0f, 32f, 4f, 10f); close() }
|
|
|
|
|
val faceSize = IntSize(faces[0].width, faces[0].height)
|
|
|
|
|
/** Shapes rebuilt in place each frame (drawing runs on the one UI thread): the up/down marker, a star, a crystal. */
|
|
|
|
|
val marker = Path()
|
|
|
|
|
val star = Path()
|
|
|
|
|
val crystal = Path()
|
|
|
|
|
|
|
|
|
|
fun DrawScope.rocket(x: Float, y: Float, s: RushSim, flicker: Float) {
|
|
|
|
|
val fin = pilotColour(s.pilot)
|
|
|
|
|
translate(x, y) {
|
|
|
|
|
scale(1.2f, 1.2f, Offset.Zero) {
|
|
|
|
|
drawPath(if (s.burstFor > 0f) bigFlame else flame, Color(0xFFFF9A3D), alpha = .8f + .2f * flicker)
|
|
|
|
|
drawPath(finL, fin); drawPath(finR, fin)
|
|
|
|
|
drawPath(body, if (s.hurtFor > 0f) Color(0xFFFFB3B3) else Color(0xFFEFF3FF))
|
|
|
|
|
drawPath(nose, fin)
|
|
|
|
|
drawCircle(Color(0xFF1B2A4E), 4.8f, Offset(0f, -3f))
|
|
|
|
|
drawImage(faces[s.pilot.ordinal], IntOffset.Zero, faceSize, IntOffset(-4, -7), IntSize(8, 8))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** A star pickup, [r] across. */
|
|
|
|
|
fun DrawScope.starAt(c: Offset, r: Float) {
|
|
|
|
|
star.reset()
|
|
|
|
|
for (k in 0 until 10) {
|
|
|
|
|
val a = -Math.PI / 2 + k * Math.PI / 5; val rad = if (k % 2 == 0) r else r * .45f
|
|
|
|
|
val px = c.x + (rad * kotlin.math.cos(a)).toFloat(); val py = c.y + (rad * kotlin.math.sin(a)).toFloat()
|
|
|
|
|
if (k == 0) star.moveTo(px, py) else star.lineTo(px, py)
|
|
|
|
|
}
|
|
|
|
|
star.close()
|
|
|
|
|
drawPath(star, RColours.Star)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@@ -83,7 +190,12 @@ internal fun OrbitRushScreen(play: ArcadePlay) {
|
|
|
|
|
val calm = Motion.reduce
|
|
|
|
|
val steady = calm || play.reduceFlashing
|
|
|
|
|
val density = LocalDensity.current
|
|
|
|
|
val art = remember(density) { OrbiteroidsArt(pilotFace(Pilot.Blaze, 96, density)) }
|
|
|
|
|
val measurer = rememberTextMeasurer()
|
|
|
|
|
val art = remember(density) {
|
|
|
|
|
RushArt(RPilot.entries.map { rushFace(it, 96, density) }.toTypedArray(),
|
|
|
|
|
measurer.measure("999", TextStyle(color = Color(0xFFFFFF00), fontSize = 22.sp, fontWeight = FontWeight.Bold)))
|
|
|
|
|
}
|
|
|
|
|
val story = remember(density) { StoryArt(density, measurer) }
|
|
|
|
|
val sim = remember { RushSim(play.difficulty) }
|
|
|
|
|
val hud = remember { RHud() }
|
|
|
|
|
val stepper = remember { FixedStep() }
|
|
|
|
@@ -92,11 +204,23 @@ internal fun OrbitRushScreen(play: ArcadePlay) {
|
|
|
|
|
var howTo by remember { mutableStateOf(false) }
|
|
|
|
|
var soundsOn by remember { mutableStateOf(play.setting("sounds")) }
|
|
|
|
|
var bestBefore by remember { mutableIntStateOf(play.best) }
|
|
|
|
|
var pilot by remember { mutableStateOf(RPilot.entries.firstOrNull { it.name == play.level["pilot"] } ?: RPilot.Blaze) }
|
|
|
|
|
var farthest by remember { mutableIntStateOf(play.level["farthest"]?.toIntOrNull() ?: 0) }
|
|
|
|
|
/** The region's name across the screen as it's entered, for a moment. */
|
|
|
|
|
var banner by remember { mutableStateOf<String?>(null) }
|
|
|
|
|
var bannerAt by remember { mutableLongStateOf(0L) }
|
|
|
|
|
val tracker = remember { RunTracker { end -> latestPlay.onRunEnd(end) } }
|
|
|
|
|
fun endRun(finished: Boolean) { tracker.end(RunEnd(sim.score, finished, "${sim.distance.toInt()} m")) }
|
|
|
|
|
fun endRun(finished: Boolean) {
|
|
|
|
|
if (sim.distance.toInt() > farthest && tracker.open) { farthest = sim.distance.toInt(); latestPlay.setLevel("farthest", farthest.toString()) }
|
|
|
|
|
tracker.end(RunEnd(sim.score, finished, "${sim.pilot.title} · ${sim.distance.toInt()} m · ${RRegion.names[sim.region]}"))
|
|
|
|
|
}
|
|
|
|
|
DisposableEffect(Unit) { onDispose { endRun(false) } }
|
|
|
|
|
fun startRun() { bestBefore = maxOf(latestPlay.best, bestBefore); sim.newRun(latestPlay.difficulty, System.nanoTime()); stepper.reset(); hud.read(sim); tracker.begin(); paused = false; stage = RStage.Play }
|
|
|
|
|
fun pause() { if (stage == RStage.Play && !paused) { paused = true; stepper.reset() } }
|
|
|
|
|
fun startRun() {
|
|
|
|
|
bestBefore = maxOf(latestPlay.best, bestBefore)
|
|
|
|
|
sim.newRun(latestPlay.difficulty, System.nanoTime(), pilot); stepper.reset(); hud.read(sim); tracker.begin(); paused = false
|
|
|
|
|
banner = "SECTOR 1 · ${RRegion.names[0].uppercase()}"; bannerAt = System.currentTimeMillis(); stage = RStage.Play
|
|
|
|
|
}
|
|
|
|
|
fun pause() { if (stage == RStage.Play && !paused) { paused = true; stepper.reset(); latestPlay.audio.pauseAll() } }
|
|
|
|
|
fun leave() { endRun(sim.over); latestPlay.onLeave() }
|
|
|
|
|
PauseWhenHidden(stage == RStage.Play && !paused) { pause() }
|
|
|
|
|
ArcadeGameLoop(running = stage == RStage.Play && !paused) { _, dt ->
|
|
|
|
@@ -104,27 +228,45 @@ internal fun OrbitRushScreen(play: ArcadePlay) {
|
|
|
|
|
var ev = 0
|
|
|
|
|
for (i in 0 until n) { sim.step(); ev = ev or sim.events }
|
|
|
|
|
if (ev != 0) {
|
|
|
|
|
// The Orbit sound kit: a ping for a star, a soft bonk for a knock, the shield's shimmer.
|
|
|
|
|
// The Orbit sound kit, with Orbit Rush's own for the abilities, the portal and each new region.
|
|
|
|
|
val audio = latestPlay.audio
|
|
|
|
|
if (ev and REvents.STAR != 0) audio.sfx(Sfx.STAR, soundsOn)
|
|
|
|
|
if (ev and REvents.SMASH != 0) audio.sfx(Sfx.BREAK, soundsOn)
|
|
|
|
|
if (ev and REvents.HIT != 0 && ev and REvents.OVER == 0) audio.sfx(Sfx.PLAYER_HIT, soundsOn)
|
|
|
|
|
if (ev and REvents.POWER != 0) audio.sfx(Sfx.POWER, soundsOn)
|
|
|
|
|
if (ev and REvents.SHIELD_ON != 0) audio.sfx(Sfx.SHIELD, soundsOn)
|
|
|
|
|
if (ev and REvents.POWER_ON != 0) audio.sfx(if (sim.active == RPower.SHIELD) Sfx.SHIELD else Sfx.LIGHT, soundsOn)
|
|
|
|
|
if (ev and REvents.CHARGED != 0) audio.sfx(Sfx.SELECT, soundsOn)
|
|
|
|
|
if (ev and REvents.ABILITY != 0) audio.sfx(when (sim.pilot) {
|
|
|
|
|
RPilot.Blaze -> Sfx.BOOST; RPilot.Drift -> Sfx.SLOWMO; RPilot.Zip -> Sfx.WHOOSH; RPilot.Luna -> Sfx.SHIELD; RPilot.Ollie -> Sfx.POWER
|
|
|
|
|
}, soundsOn)
|
|
|
|
|
if (ev and REvents.PORTAL != 0) { audio.sfx(Sfx.PORTAL, soundsOn); banner = "PAGE 999 · THE WIZARD TIPS HIS HAT"; bannerAt = System.currentTimeMillis() }
|
|
|
|
|
if (ev and REvents.REGION != 0) {
|
|
|
|
|
audio.sfx(Sfx.REGION, soundsOn)
|
|
|
|
|
banner = "SECTOR ${sim.region + 1} · ${RRegion.names[sim.region].uppercase()}"; bannerAt = System.currentTimeMillis()
|
|
|
|
|
}
|
|
|
|
|
if (ev and REvents.OVER != 0) audio.sfx(if (sim.score > bestBefore) Sfx.NEW_BEST else Sfx.GAME_OVER, soundsOn)
|
|
|
|
|
}
|
|
|
|
|
hud.read(sim)
|
|
|
|
|
if (sim.over) { endRun(true); stage = RStage.Result }
|
|
|
|
|
}
|
|
|
|
|
LaunchedEffect(bannerAt) { if (banner != null) { kotlinx.coroutines.delay(2_600); banner = null } }
|
|
|
|
|
val focus = remember { FocusRequester() }
|
|
|
|
|
LaunchedEffect(stage, paused) { if (stage == RStage.Play && !paused) runCatching { focus.requestFocus() } }
|
|
|
|
|
BackHandler(stage == RStage.Play && !paused) { pause() }
|
|
|
|
|
|
|
|
|
|
if (stage == RStage.Title) {
|
|
|
|
|
ClassicTitle(gameDef, ArcadeBackdrop.DeepSpace, tv.orbit.classic.OrbCharacter.Blaze.colour, "The storm's behind us. Go!",
|
|
|
|
|
listOf("Your best" to if (play.best > 0) "%,d".format(play.best) else "Not played yet"), timed = true, difficulty = play.difficulty,
|
|
|
|
|
refocus = !howTo, onPlay = ::startRun, onHowTo = { howTo = true }, onBack = { latestPlay.onLeave() }, kicker = "AN ORBIT ARCADE ORIGINAL · PROTOTYPE",
|
|
|
|
|
mode = "Asteroid Alley",
|
|
|
|
|
note = "Blaze flies on his own. ◀▶ change lane round a rock, ▲ rises over a low satellite, ▼ dives under a tall signal gate. Each lane lights up before something arrives: red, change lane; yellow, rise; cyan, dive. Grab a shield and OK puts it on.")
|
|
|
|
|
ClassicTitle(gameDef, ArcadeBackdrop.DeepSpace, pilotColour(pilot), "The storm's behind us. Go!",
|
|
|
|
|
listOf("Your best" to if (play.best > 0) "%,d".format(play.best) else "Not played yet",
|
|
|
|
|
"Furthest" to if (farthest > 0) "%,d m".format(farthest) else "—"),
|
|
|
|
|
timed = true, difficulty = play.difficulty,
|
|
|
|
|
refocus = !howTo, onPlay = ::startRun, onHowTo = { howTo = true }, onBack = { latestPlay.onLeave() }, kicker = "AN ORBIT ARCADE ORIGINAL",
|
|
|
|
|
mode = "${pilot.title} · ${pilot.ability}", modes = RPilot.entries.size,
|
|
|
|
|
onMode = { pilot = RPilot.entries[(pilot.ordinal + 1) % RPilot.entries.size]; latestPlay.setLevel("pilot", pilot.name) },
|
|
|
|
|
playLabel = "Fly with ${pilot.title}",
|
|
|
|
|
note = "${pilot.title}'s ability, ${pilot.ability}: ${pilot.line}. Stars charge it; OK sets it off when no power-up is held. " +
|
|
|
|
|
"◀▶ change lane round anything solid, ▲ rises over a low thing, ▼ dives under a tall one: each lane lights up first, red, yellow or cyan. " +
|
|
|
|
|
"Fly on from Asteroid Alley to Broadcast Boulevard, The Static Zone and The Forbidden Frequency" +
|
|
|
|
|
if (play.difficulty == Difficulty.Gentle) ". Gentle: slower, one hazard at a time, an extra bar of hull and earlier warnings." else ".")
|
|
|
|
|
if (howTo) HowToPlayCard(gameDef, firstRun = false, everyTime = null, onEveryTime = {}, onPlay = { howTo = false }, onBack = { howTo = false })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@@ -137,54 +279,80 @@ internal fun OrbitRushScreen(play: ArcadePlay) {
|
|
|
|
|
ArcadeKey.Right -> { val was = sim.lane; sim.right(); if (sim.lane != was) latestPlay.audio.sfx(Sfx.WHOOSH, soundsOn) }
|
|
|
|
|
ArcadeKey.Up -> if (native.repeatCount == 0 && !sim.over) { sim.rise(); latestPlay.audio.sfx(Sfx.RISE, soundsOn) }
|
|
|
|
|
ArcadeKey.Down -> if (native.repeatCount == 0 && !sim.over) { sim.dive(); latestPlay.audio.sfx(Sfx.DIVE, soundsOn) }
|
|
|
|
|
ArcadeKey.Ok -> if (native.repeatCount == 0) sim.usePower()
|
|
|
|
|
ArcadeKey.Ok -> if (native.repeatCount == 0 && !sim.usePower()) latestPlay.audio.sfx(Sfx.NOPE, soundsOn)
|
|
|
|
|
else -> return@gameKeys false
|
|
|
|
|
}
|
|
|
|
|
true
|
|
|
|
|
}
|
|
|
|
|
val gentle = play.difficulty == Difficulty.Gentle
|
|
|
|
|
Box(Modifier.fillMaxSize().then(keys)) {
|
|
|
|
|
Box(Modifier.fillMaxSize().rushSky())
|
|
|
|
|
Canvas(Modifier.fillMaxSize()) { hud.frame; drawRush(art, sim, calm, steady) }
|
|
|
|
|
Box(Modifier.fillMaxSize().rushSky(if (hud.secret) SecretLook else RegionLooks[hud.region]))
|
|
|
|
|
Canvas(Modifier.fillMaxSize()) {
|
|
|
|
|
hud.frame
|
|
|
|
|
drawRush(art, sim, calm, steady, gentle)
|
|
|
|
|
if (sim.secretFor > 0f) with(story) { wizard(size.width * .78f, size.height * .3f, size.height * .26f, if (calm) 1f else minOf(1f, (RushSim.SECRET_TIME - sim.secretFor) / 1.2f), tinted = false) }
|
|
|
|
|
}
|
|
|
|
|
Column(Modifier.fillMaxSize().padding(start = 32.dp, end = 32.dp, top = 20.dp, bottom = 10.dp)) {
|
|
|
|
|
Row(Modifier.fillMaxWidth()) {
|
|
|
|
|
Column(Modifier.weight(1f)) {
|
|
|
|
|
Text("SCORE", color = ArcadeColours.Muted, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 2.sp)
|
|
|
|
|
Text("%,d".format(hud.score), color = ArcadeColours.Ink, fontFamily = Anton, fontSize = 30.sp)
|
|
|
|
|
Text("★ ${hud.stars}", color = RColours.Star, fontSize = 16.sp, fontWeight = FontWeight.SemiBold)
|
|
|
|
|
Text("★ ${hud.stars} · %,d m".format(hud.metres), color = RColours.Star, fontSize = 16.sp, fontWeight = FontWeight.SemiBold)
|
|
|
|
|
Text(if (hud.secret) "Page 999 · the secret route" else RRegion.names[hud.region], color = ArcadeColours.Muted, fontSize = 14.sp)
|
|
|
|
|
}
|
|
|
|
|
Column(horizontalAlignment = Alignment.End) {
|
|
|
|
|
Text("HULL", color = ArcadeColours.Muted, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 2.sp)
|
|
|
|
|
Row(horizontalArrangement = Arrangement.spacedBy(3.dp)) { for (i in 0 until RushSim.HULL) Box(Modifier.size(28.dp, 10.dp).background(if (i < hud.hull) Color(0xFF4CD98A) else Color(0xFF1C2A5A), RoundedCornerShape(3.dp))) }
|
|
|
|
|
Row(horizontalArrangement = Arrangement.spacedBy(3.dp)) { for (i in 0 until hud.hullMax) Box(Modifier.size(28.dp, 10.dp).background(if (i < hud.hull) Color(0xFF4CD98A) else Color(0xFF1C2A5A), RoundedCornerShape(3.dp))) }
|
|
|
|
|
Spacer(Modifier.height(6.dp))
|
|
|
|
|
Text(when { hud.shieldSecs > 0 -> "Orbit Shield on: ${hud.shieldSecs} s"; hud.shieldHeld -> "OK: Orbit Shield"; else -> "No power-up" },
|
|
|
|
|
color = if (hud.shieldHeld || hud.shieldSecs > 0) RColours.Shield else ArcadeColours.Muted, fontSize = 15.sp, fontWeight = FontWeight.SemiBold)
|
|
|
|
|
Text(when {
|
|
|
|
|
hud.activeSecs > 0 && hud.active != RPower.NONE -> "${RPower.titles[hud.active]} on: ${hud.activeSecs} s"
|
|
|
|
|
hud.held != RPower.NONE -> "OK: ${RPower.titles[hud.held]}"
|
|
|
|
|
hud.charge >= 10 -> "OK: ${sim.pilot.ability}"
|
|
|
|
|
else -> "No power-up"
|
|
|
|
|
}, color = when {
|
|
|
|
|
hud.active != RPower.NONE && hud.activeSecs > 0 -> RColours.power(hud.active)
|
|
|
|
|
hud.held != RPower.NONE -> RColours.power(hud.held)
|
|
|
|
|
hud.charge >= 10 -> pilotColour(sim.pilot)
|
|
|
|
|
else -> ArcadeColours.Muted
|
|
|
|
|
}, fontSize = 15.sp, fontWeight = FontWeight.SemiBold)
|
|
|
|
|
// The ability's charge: ten pips in the pilot's colour.
|
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(2.dp)) {
|
|
|
|
|
Text("${sim.pilot.ability} ", color = ArcadeColours.Muted, fontSize = 13.sp)
|
|
|
|
|
for (i in 0 until 10) Box(Modifier.size(7.dp, 9.dp).background(if (i < hud.charge) pilotColour(sim.pilot) else Color(0xFF1C2A5A), RoundedCornerShape(2.dp)))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Spacer(Modifier.weight(1f))
|
|
|
|
|
KeyFooter(listOf(Control("◀▶", "Lane"), Control("▲", "Rise"), Control("▼", "Dive"), Control("OK", "Power-up"), Control("Back", "Pause")), note = "Asteroid Alley · prototype")
|
|
|
|
|
banner?.let { Text(it, Modifier.align(Alignment.CenterHorizontally).background(Color(0xCC0A1030), RoundedCornerShape(10.dp)).padding(horizontal = 18.dp, vertical = 6.dp),
|
|
|
|
|
color = ArcadeColours.Ink, fontFamily = Anton, fontSize = 26.sp) }
|
|
|
|
|
Spacer(Modifier.weight(1f))
|
|
|
|
|
KeyFooter(listOf(Control("◀▶", "Lane"), Control("▲", "Rise"), Control("▼", "Dive"), Control("OK", "Power-up or ability"), Control("Back", "Pause")),
|
|
|
|
|
note = "${sim.pilot.title} · ${RRegion.names[hud.region]}")
|
|
|
|
|
}
|
|
|
|
|
if (stage == RStage.Result) ClassicResult(gameDef, "ORBIT RUSH · ${sim.distance.toInt()} M THROUGH ASTEROID ALLEY", "SCORE", "%,d".format(sim.score),
|
|
|
|
|
if (stage == RStage.Result) ClassicResult(gameDef, "ORBIT RUSH · ${sim.distance.toInt()} M · ${RRegion.names[sim.region].uppercase()}", "SCORE", "%,d".format(sim.score),
|
|
|
|
|
newBest = sim.score > bestBefore && sim.score > 0, previous = previousLine(gameDef.scoreKind, bestBefore, gameDef.title),
|
|
|
|
|
detail = "${sim.stars} stars · ${sim.dodged} dodged · the static storm caught up", cheer = Mascot.Zip, onAgain = { endRun(sim.over); startRun() }, onBack = ::leave)
|
|
|
|
|
if (paused && stage == RStage.Play) ArcadePauseMenu(gameDef, "Orbit Rush · ${sim.distance.toInt()} m · ${"%,d".format(sim.score)}",
|
|
|
|
|
onResume = { paused = false; stepper.reset() }, onRestart = { endRun(false); startRun() }, onExit = ::leave,
|
|
|
|
|
detail = "${sim.pilot.title} · ${sim.stars} stars · ${sim.dodged} dodged" + (if (sim.portals > 0) " · through the 999 portal" else "") + " · the static storm caught up",
|
|
|
|
|
cheer = when (sim.pilot) { RPilot.Ollie -> Mascot.Ollie; RPilot.Blaze -> Mascot.Blaze; RPilot.Zip -> Mascot.Zip; RPilot.Drift -> Mascot.Drift; RPilot.Luna -> Mascot.Luna },
|
|
|
|
|
onAgain = { endRun(sim.over); startRun() }, onBack = ::leave)
|
|
|
|
|
if (paused && stage == RStage.Play) ArcadePauseMenu(gameDef, "Orbit Rush · ${sim.pilot.title} · ${sim.distance.toInt()} m · ${"%,d".format(sim.score)}",
|
|
|
|
|
onResume = { paused = false; stepper.reset(); latestPlay.audio.resumeAll() }, onRestart = { endRun(false); startRun() }, onExit = ::leave,
|
|
|
|
|
sound = if (soundsOn) "Effects on" else "Effects off", onSound = { soundsOn = !soundsOn; latestPlay.setSetting("sounds", soundsOn) })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** The sky and the track's lanes, drawn once in their own layer: only what moves is drawn each frame. */
|
|
|
|
|
private fun Modifier.rushSky(): Modifier = graphicsLayer().drawWithCache {
|
|
|
|
|
/** The sky and the track's lanes in the region's colours, drawn once in their own layer (again only when the region changes). */
|
|
|
|
|
private fun Modifier.rushSky(look: RegionLook): Modifier = graphicsLayer().drawWithCache {
|
|
|
|
|
val w = size.width; val h = size.height
|
|
|
|
|
val rnd = java.util.Random(7)
|
|
|
|
|
val stars = FloatArray(120 * 3) { k -> when (k % 3) { 0 -> rnd.nextFloat() * w; 1 -> rnd.nextFloat() * h * .4f; else -> .5f + rnd.nextFloat() * 1.5f } }
|
|
|
|
|
val horizon = h * HORIZON; val base = h
|
|
|
|
|
val track = Path().apply { moveTo(w / 2 - LANE_W * w * .2f * 1.5f, horizon); lineTo(w / 2 + LANE_W * w * .2f * 1.5f, horizon); lineTo(w / 2 + LANE_W * w * 1.5f, base); lineTo(w / 2 - LANE_W * w * 1.5f, base); close() }
|
|
|
|
|
onDrawBehind {
|
|
|
|
|
drawRect(Brush.verticalGradient(listOf(Color(0xFF040A1E), Color(0xFF0E1A48)), 0f, horizon))
|
|
|
|
|
drawRect(Color(0xFF060C24), Offset(0f, horizon), Size(w, h - horizon))
|
|
|
|
|
drawRect(Brush.verticalGradient(listOf(look.skyTop, look.skyLow), 0f, horizon))
|
|
|
|
|
drawRect(look.ground, Offset(0f, horizon), Size(w, h - horizon))
|
|
|
|
|
for (i in 0 until 120) drawCircle(Color.White.copy(alpha = .3f + stars[i * 3 + 2] / 5), stars[i * 3 + 2], Offset(stars[i * 3], stars[i * 3 + 1]))
|
|
|
|
|
drawPath(track, RColours.Track)
|
|
|
|
|
for (b in 0..3) { val off = b - 1.5f; drawLine(RColours.Edge, Offset(w / 2 + off * LANE_W * w * .2f, horizon), Offset(w / 2 + off * LANE_W * w, base), 2f) }
|
|
|
|
|
drawPath(track, look.track)
|
|
|
|
|
for (b in 0..3) { val off = b - 1.5f; drawLine(look.edge, Offset(w / 2 + off * LANE_W * w * .2f, horizon), Offset(w / 2 + off * LANE_W * w, base), 2f) }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -192,52 +360,71 @@ private fun Modifier.rushSky(): Modifier = graphicsLayer().drawWithCache {
|
|
|
|
|
private const val HORIZON = .34f
|
|
|
|
|
private const val LANE_W = .2f
|
|
|
|
|
|
|
|
|
|
/** The perspective: a thing at distance [z] is drawn at scale s (1 at Blaze, .2 at the horizon) and at height y. */
|
|
|
|
|
/** The perspective: a thing at distance [z] is drawn at scale s (1 at the pilot, .2 at the horizon) and at height y. */
|
|
|
|
|
private fun scaleAt(z: Float) = 1f / (1f + 4f * (z / FAR))
|
|
|
|
|
private fun DrawScope.yAt(s: Float) = size.height * HORIZON + (size.height * .9f - size.height * HORIZON) * (s - .2f) / .8f
|
|
|
|
|
private fun DrawScope.xAt(laneX: Float, s: Float) = size.width / 2 + (laneX - 1f) * LANE_W * size.width * s
|
|
|
|
|
|
|
|
|
|
/** The up/down marker's shape, made once and reused each frame (drawing runs on the one UI thread). */
|
|
|
|
|
private val markerPath = androidx.compose.ui.graphics.Path()
|
|
|
|
|
|
|
|
|
|
private fun DrawScope.drawRush(art: OrbiteroidsArt, s: RushSim, calm: Boolean, steady: Boolean) {
|
|
|
|
|
private fun DrawScope.drawRush(art: RushArt, s: RushSim, calm: Boolean, steady: Boolean, gentle: Boolean) {
|
|
|
|
|
val w = size.width; val h = size.height
|
|
|
|
|
val look = RegionLooks[s.region]
|
|
|
|
|
// Dashes rushing past on the lane lines (still with Reduce motion).
|
|
|
|
|
val shift = if (calm) 0f else (s.distance % 10f) / 10f
|
|
|
|
|
val dash = if (s.secretFor > 0f) SecretLook.edge else look.edge
|
|
|
|
|
for (b in 0..3) for (k in 0 until 8) {
|
|
|
|
|
val z = FAR * (1f - (k + shift) / 8f)
|
|
|
|
|
val sc = scaleAt(z); val off = b - 1.5f
|
|
|
|
|
drawCircle(RColours.Edge.copy(alpha = .4f + .6f * sc), 2f + 3f * sc, Offset(w / 2 + off * LANE_W * w * sc, yAt(sc)))
|
|
|
|
|
drawCircle(dash.copy(alpha = .4f + .6f * sc), 2f + 3f * sc, Offset(w / 2 + off * LANE_W * w * sc, yAt(sc)))
|
|
|
|
|
}
|
|
|
|
|
// Warnings: a lane lights in the colour of what's coming down it (steady with Reduce flashing).
|
|
|
|
|
for (i in 0 until RushSim.MAX) {
|
|
|
|
|
if (!s.on[i] || s.kind[i] > RKind.TALL || s.z[i] > WARN) continue
|
|
|
|
|
if (!s.on[i] || s.kind[i] > RKind.TALL || s.z[i] > s.warnAt) continue
|
|
|
|
|
val a = if (steady) .35f else .25f + .15f * kotlin.math.sin(s.clock * 12f)
|
|
|
|
|
val sc = scaleAt(0f)
|
|
|
|
|
drawRect(RColours.warn(s.kind[i]).copy(alpha = a), Offset(xAt(s.laneOf[i].toFloat(), sc) - LANE_W * w * .5f, h * .9f), Size(LANE_W * w, h * .06f))
|
|
|
|
|
}
|
|
|
|
|
// The Static Zone glitches: hazards shiver a little (never with Reduce motion or flashing, nor on Gentle).
|
|
|
|
|
val shiver = s.region == RRegion.STATIC && !steady && !gentle
|
|
|
|
|
// Far things first, so near ones are drawn over them.
|
|
|
|
|
for (pass in 0 until 2) for (i in 0 until RushSim.MAX) {
|
|
|
|
|
if (!s.on[i]) continue
|
|
|
|
|
val z = s.z[i]
|
|
|
|
|
if ((pass == 0) != (z > FAR / 2)) continue
|
|
|
|
|
val sc = scaleAt(z); val x = xAt(s.laneOf[i].toFloat(), sc); val y = yAt(sc); val u = LANE_W * w * sc
|
|
|
|
|
val sc = scaleAt(z); val u = LANE_W * w * sc
|
|
|
|
|
val x = xAt(s.laneOf[i].toFloat(), sc) + if (shiver && s.kind[i] <= RKind.TALL) u * .03f * kotlin.math.sin(s.clock * 40f + i) else 0f
|
|
|
|
|
val y = yAt(sc)
|
|
|
|
|
when (s.kind[i]) {
|
|
|
|
|
// A rock: a big chunky boulder filling the lane.
|
|
|
|
|
RKind.ROCK -> { drawCircle(RColours.RockDark, u * .42f, Offset(x, y - u * .3f)); drawCircle(RColours.Rock, u * .36f, Offset(x - u * .04f, y - u * .34f)); drawCircle(RColours.RockDark, u * .08f, Offset(x + u * .1f, y - u * .42f)) }
|
|
|
|
|
// A low satellite: a wide flat bar along the track (rise over it).
|
|
|
|
|
RKind.LOW -> { drawRect(RColours.Low, Offset(x - u * .45f, y - u * .16f), Size(u * .9f, u * .14f)); drawRect(RColours.Panel, Offset(x - u * .42f, y - u * .14f), Size(u * .3f, u * .1f)); drawRect(RColours.Panel, Offset(x + u * .12f, y - u * .14f), Size(u * .3f, u * .1f)) }
|
|
|
|
|
// A tall signal gate: two posts and a bar overhead, a gap underneath (dive under it).
|
|
|
|
|
RKind.TALL -> { drawRect(RColours.Tall, Offset(x - u * .45f, y - u * .9f), Size(u * .08f, u * .9f)); drawRect(RColours.Tall, Offset(x + u * .37f, y - u * .9f), Size(u * .08f, u * .9f)); drawRect(RColours.Tall, Offset(x - u * .45f, y - u * .9f), Size(u * .9f, u * .3f)) }
|
|
|
|
|
RKind.STAR -> drawPath(starPath(Offset(x, y - u * .3f), u * .16f, u * .07f, 0f), RColours.Star)
|
|
|
|
|
RKind.SHIELD -> { drawCircle(RColours.Shield, u * .18f, Offset(x, y - u * .3f)); drawCircle(Color.White, u * .18f, Offset(x, y - u * .3f), style = Stroke(u * .03f)) }
|
|
|
|
|
RKind.ROCK -> block(s.region, look, x, y, u, art)
|
|
|
|
|
RKind.LOW -> low(s.region, look, x, y, u)
|
|
|
|
|
RKind.TALL -> tall(s.region, look, x, y, u)
|
|
|
|
|
RKind.STAR -> with(art) { starAt(Offset(x, y - u * .3f), u * .16f) }
|
|
|
|
|
RKind.POWER -> {
|
|
|
|
|
val c = Offset(x, y - u * .3f); val col = RColours.power(s.power[i])
|
|
|
|
|
drawCircle(col, u * .18f, c); drawCircle(Color.White, u * .18f, c, style = Stroke(u * .03f))
|
|
|
|
|
when (s.power[i]) {
|
|
|
|
|
RPower.SHIELD -> drawCircle(Color.White, u * .09f, c, style = Stroke(u * .03f))
|
|
|
|
|
RPower.MAGNET -> {
|
|
|
|
|
drawLine(Color.White, Offset(c.x - u * .07f, c.y - u * .07f), Offset(c.x - u * .07f, c.y + u * .04f), u * .035f)
|
|
|
|
|
drawLine(Color.White, Offset(c.x + u * .07f, c.y - u * .07f), Offset(c.x + u * .07f, c.y + u * .04f), u * .035f)
|
|
|
|
|
drawLine(Color.White, Offset(c.x - u * .07f, c.y + u * .04f), Offset(c.x + u * .07f, c.y + u * .04f), u * .035f)
|
|
|
|
|
}
|
|
|
|
|
else -> { drawCircle(Color.White, u * .04f, Offset(c.x - u * .05f, c.y)); drawCircle(Color.White, u * .04f, Offset(c.x + u * .05f, c.y)) }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
RKind.PORTAL -> {
|
|
|
|
|
val c = Offset(x, y - u * .45f)
|
|
|
|
|
drawCircle(RColours.Portal.copy(alpha = .35f), u * .46f, c)
|
|
|
|
|
drawCircle(RColours.Portal, u * .46f, c, style = Stroke(u * .07f))
|
|
|
|
|
drawCircle(Color(0xFF00005A), u * .36f, c)
|
|
|
|
|
val sign = art.portalSign
|
|
|
|
|
val k = (u * .5f) / sign.size.width.coerceAtLeast(1)
|
|
|
|
|
scale(k, k, c) { drawText(sign, topLeft = Offset(c.x - sign.size.width / 2f, c.y - sign.size.height / 2f)) }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Blaze's rocket (Paul, 9 November 2026: "harder to tell when you jump"). Up or down reads four ways at once: his
|
|
|
|
|
// shadow on the track (small and faint when he's risen, big and dark when he's dived), the rocket itself (bigger as he
|
|
|
|
|
// comes up towards you, smaller down low), how high he sits, and a marker in the colour of what it gets him past:
|
|
|
|
|
// yellow ▲ over a low satellite, cyan ▼ under a gate, with a bar for how long he stays there. Nothing flashes, and with
|
|
|
|
|
// Reduce motion he still moves (the shadow and marker don't depend on it).
|
|
|
|
|
// The pilot (Paul, 9 November 2026: "harder to tell when you jump"). Up or down reads four ways at once: the shadow on
|
|
|
|
|
// the track (small and faint when risen, big and dark when dived), the rocket's size, how high it sits, and a marker in
|
|
|
|
|
// the colour of what it gets them past (yellow ▲, cyan ▼) with a bar for how long they stay there.
|
|
|
|
|
val bx = xAt(s.laneX, 1f)
|
|
|
|
|
val k = h / 260f
|
|
|
|
|
val lift = s.lift
|
|
|
|
@@ -246,14 +433,17 @@ private fun DrawScope.drawRush(art: OrbiteroidsArt, s: RushSim, calm: Boolean, s
|
|
|
|
|
val shadowW = 30f * k * (1f - .45f * lift.coerceAtLeast(0f) + .15f * (-lift).coerceAtLeast(0f))
|
|
|
|
|
drawOval(Color.Black.copy(alpha = .45f - .25f * lift.coerceAtLeast(0f) + .1f * (-lift).coerceAtLeast(0f)), Offset(bx - shadowW, ground - shadowW * .28f), Size(shadowW * 2f, shadowW * .56f))
|
|
|
|
|
val shipScale = k * (1f + .3f * lift.coerceAtLeast(0f) - .22f * (-lift).coerceAtLeast(0f))
|
|
|
|
|
if (s.shieldFor > 0f) drawCircle(RColours.Shield.copy(alpha = .3f), 34f * shipScale, Offset(bx, by))
|
|
|
|
|
scale(shipScale, shipScale, Offset(bx, by)) { with(art) { ship(bx, by, 0f, s.hurtFor > 0f, if (calm) 1f else kotlin.math.sin(s.clock * 30f)) } }
|
|
|
|
|
// Speed Burst: streaks behind (none with Reduce motion); shields: a bubble in their colour; the magnet: a ring.
|
|
|
|
|
if (s.burstFor > 0f && !calm) for (j in 0 until 6) { val sx = bx + (j - 2.5f) * 7f * k; drawLine(pilotColour(s.pilot).copy(alpha = .5f), Offset(sx, by + 20f * shipScale), Offset(sx, by + (46f + (j % 3) * 10f) * shipScale), 2f * k) }
|
|
|
|
|
if (s.shielded) drawCircle((if (s.abilityShieldFor > 0f) pilotColour(s.pilot) else RColours.Shield).copy(alpha = .3f), 34f * shipScale, Offset(bx, by))
|
|
|
|
|
if (s.active == RPower.MAGNET && s.activeFor > 0f) drawCircle(RColours.Magnet.copy(alpha = .5f), 40f * shipScale, Offset(bx, by), style = Stroke(2f * k))
|
|
|
|
|
scale(shipScale, shipScale, Offset(bx, by)) { with(art) { rocket(bx, by, s, if (calm) 1f else kotlin.math.sin(s.clock * 30f)) } }
|
|
|
|
|
if (s.height != RHeight.LEVEL && s.heightFor > 0f) {
|
|
|
|
|
val up = s.height == RHeight.RISE
|
|
|
|
|
val c = RColours.warn(if (up) RKind.LOW else RKind.TALL)
|
|
|
|
|
val my = if (up) by - 40f * shipScale else by + 34f * shipScale
|
|
|
|
|
val a = 13f * k
|
|
|
|
|
val arrow = markerPath.apply {
|
|
|
|
|
val arrow = art.marker.apply {
|
|
|
|
|
reset()
|
|
|
|
|
if (up) { moveTo(bx, my - a); lineTo(bx + a, my); lineTo(bx - a, my) } else { moveTo(bx, my + a); lineTo(bx + a, my); lineTo(bx - a, my) }
|
|
|
|
|
close()
|
|
|
|
@@ -264,8 +454,58 @@ private fun DrawScope.drawRush(art: OrbiteroidsArt, s: RushSim, calm: Boolean, s
|
|
|
|
|
drawRect(c.copy(alpha = .3f), Offset(bx - 16f * k, barY), Size(32f * k, 3f * k))
|
|
|
|
|
drawRect(c, Offset(bx - 16f * k, barY), Size(32f * k * left, 3f * k))
|
|
|
|
|
}
|
|
|
|
|
// The static storm behind, closer as he's hit: a band of grey along the bottom (dots still with Reduce motion).
|
|
|
|
|
// Slow-mo: the world takes on Drift's cool blue. Warp Ahead: a soft fade of Zip's pink (gentler with Reduce flashing).
|
|
|
|
|
if (s.slowFor > 0f) drawRect(OrbCharacter.Drift.colour.copy(alpha = .12f), Offset.Zero, size)
|
|
|
|
|
if (s.warpFor > 0f) drawRect(OrbCharacter.Zip.colour.copy(alpha = (if (steady) .12f else .35f) * (s.warpFor / .6f)), Offset.Zero, size)
|
|
|
|
|
// The static storm behind, closer at each hit: a band of grey along the bottom (no dots with Reduce motion, nor on Gentle).
|
|
|
|
|
val band = h * (.06f + .14f * (1f - s.storm))
|
|
|
|
|
drawRect(Brush.verticalGradient(listOf(Color.Transparent, Color(0xFF8D95AE).copy(alpha = .55f)), h - band, h), Offset(0f, h - band), Size(w, band))
|
|
|
|
|
if (!calm) for (k2 in 0 until 40) { val sx = ((k2 * 97 + (s.clock * 400).toInt() * 13) % 1000) / 1000f * w; val sy = h - band * (((k2 * 37) % 100) / 100f); drawRect(Color.White.copy(alpha = .35f), Offset(sx, sy), Size(3f, 2f)) }
|
|
|
|
|
if (!calm && !gentle) for (k2 in 0 until 40) { val sx = ((k2 * 97 + (s.clock * 400).toInt() * 13) % 1000) / 1000f * w; val sy = h - band * (((k2 * 37) % 100) / 100f); drawRect(Color.White.copy(alpha = .35f), Offset(sx, sy), Size(3f, 2f)) }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Solid in its lane at every height (red: change lane). Each region's own: a rock, a broken TV, a rogue-pixel cluster, a dark crystal. */
|
|
|
|
|
private fun DrawScope.block(region: Int, look: RegionLook, x: Float, y: Float, u: Float, art: RushArt) {
|
|
|
|
|
when (region) {
|
|
|
|
|
RRegion.ALLEY -> { drawCircle(look.blockDark, u * .42f, Offset(x, y - u * .3f)); drawCircle(look.block, u * .36f, Offset(x - u * .04f, y - u * .34f)); drawCircle(look.blockDark, u * .08f, Offset(x + u * .1f, y - u * .42f)) }
|
|
|
|
|
RRegion.BOULEVARD -> {
|
|
|
|
|
// A broken old telly: its cabinet, a cracked grey screen, two knobs.
|
|
|
|
|
drawRect(look.block, Offset(x - u * .4f, y - u * .66f), Size(u * .8f, u * .6f))
|
|
|
|
|
drawRect(Color(0xFF8D95AE), Offset(x - u * .32f, y - u * .58f), Size(u * .5f, u * .44f))
|
|
|
|
|
drawLine(look.blockDark, Offset(x - u * .25f, y - u * .52f), Offset(x - u * .05f, y - u * .3f), u * .025f)
|
|
|
|
|
drawLine(look.blockDark, Offset(x - u * .05f, y - u * .3f), Offset(x + u * .1f, y - u * .45f), u * .025f)
|
|
|
|
|
drawCircle(look.edge, u * .04f, Offset(x + u * .28f, y - u * .5f)); drawCircle(look.edge, u * .04f, Offset(x + u * .28f, y - u * .34f))
|
|
|
|
|
}
|
|
|
|
|
RRegion.STATIC -> {
|
|
|
|
|
// Rogue pixels: a chunky cluster of squares.
|
|
|
|
|
val p = u * .17f
|
|
|
|
|
for (r in 0 until 3) for (c in 0 until 3) if ((r + c) % 3 != 2) drawRect(if ((r * 3 + c) % 2 == 0) look.block else look.blockDark, Offset(x - u * .3f + c * p * 1.15f, y - u * .66f + r * p * 1.15f), Size(p, p))
|
|
|
|
|
}
|
|
|
|
|
else -> {
|
|
|
|
|
// A dark crystal of the forbidden frequency.
|
|
|
|
|
val path = art.crystal.apply { reset(); moveTo(x, y - u * .8f); lineTo(x + u * .32f, y - u * .3f); lineTo(x, y - u * .05f); lineTo(x - u * .32f, y - u * .3f); close() }
|
|
|
|
|
drawPath(path, look.block); drawLine(look.lowLight, Offset(x, y - u * .8f), Offset(x, y - u * .05f), u * .02f)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Low along the track (yellow: rise over it): a satellite, a dish array, an interference band, a barrier of the 999 frequency. */
|
|
|
|
|
private fun DrawScope.low(region: Int, look: RegionLook, x: Float, y: Float, u: Float) {
|
|
|
|
|
when (region) {
|
|
|
|
|
RRegion.ALLEY -> { drawRect(look.low, Offset(x - u * .45f, y - u * .16f), Size(u * .9f, u * .14f)); drawRect(look.lowLight, Offset(x - u * .42f, y - u * .14f), Size(u * .3f, u * .1f)); drawRect(look.lowLight, Offset(x + u * .12f, y - u * .14f), Size(u * .3f, u * .1f)) }
|
|
|
|
|
RRegion.BOULEVARD -> { drawRect(look.low, Offset(x - u * .45f, y - u * .1f), Size(u * .9f, u * .08f)); for (d in -1..1) drawArc(look.lowLight, 200f, 140f, false, Offset(x + d * u * .3f - u * .1f, y - u * .26f), Size(u * .2f, u * .2f), style = Stroke(u * .03f)) }
|
|
|
|
|
RRegion.STATIC -> { for (j in 0 until 5) drawLine(if (j % 2 == 0) look.lowLight else look.low, Offset(x - u * .45f + j * u * .18f, y - u * .2f + (j % 2) * u * .1f), Offset(x - u * .27f + j * u * .18f, y - u * .1f - (j % 2) * u * .1f), u * .05f) }
|
|
|
|
|
else -> { drawRect(look.low, Offset(x - u * .45f, y - u * .18f), Size(u * .9f, u * .14f)); for (j in 0 until 3) drawCircle(look.lowLight, u * .035f, Offset(x - u * .25f + j * u * .25f, y - u * .11f)) }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Tall with a gap underneath (cyan: dive under it): a signal gate in each region's colours. */
|
|
|
|
|
private fun DrawScope.tall(region: Int, look: RegionLook, x: Float, y: Float, u: Float) {
|
|
|
|
|
drawRect(look.tall, Offset(x - u * .45f, y - u * .9f), Size(u * .08f, u * .9f)); drawRect(look.tall, Offset(x + u * .37f, y - u * .9f), Size(u * .08f, u * .9f))
|
|
|
|
|
drawRect(look.tall, Offset(x - u * .45f, y - u * .9f), Size(u * .9f, u * .3f))
|
|
|
|
|
when (region) {
|
|
|
|
|
RRegion.BOULEVARD -> { drawLine(look.tall, Offset(x, y - u * .9f), Offset(x, y - u * 1.1f), u * .03f); drawCircle(Color(0xFFFFDE59), u * .04f, Offset(x, y - u * 1.1f)) }
|
|
|
|
|
RRegion.STATIC -> for (j in 0 until 4) drawRect(Color.White.copy(alpha = .5f), Offset(x - u * .38f + j * u * .2f, y - u * .84f), Size(u * .08f, u * .05f))
|
|
|
|
|
RRegion.FORBIDDEN -> drawCircle(look.lowLight, u * .06f, Offset(x, y - u * .75f))
|
|
|
|
|
else -> {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|