|
|
|
@@ -35,13 +35,13 @@ import kotlin.math.abs
|
|
|
|
|
import kotlin.math.sin
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Orb-Man (Paul, 5 November 2026): a maze chase starring the Tots mascot. Clear every star from Orbit's own maze while four
|
|
|
|
|
* space rocks give chase; a power hexagon makes the rocks take fright, the screen glows, and for a while they can be caught.
|
|
|
|
|
* Orb-Man (Paul, 5 November 2026): a maze chase starring the Tots mascot. Clear every star from Orbit's own maze while four of
|
|
|
|
|
* Orbit's sky characters give chase ([OrbCharacter]); a power hexagon makes them take fright, the screen glows, and for a while they can be caught.
|
|
|
|
|
* Each cleared maze is a level, a little quicker than the last. The game itself has no screen in it, so it can be tested.
|
|
|
|
|
*/
|
|
|
|
|
internal const val ORB_TICK_MS = 20L
|
|
|
|
|
|
|
|
|
|
/** The maze's left half and middle column; the right half mirrors it. # wall, . star, o power hexagon, - the rocks' door, H their den, P start. */
|
|
|
|
|
/** The maze's left half and middle column; the right half mirrors it. # wall, . star, o power hexagon, - the den door, H their den, P start. */
|
|
|
|
|
private val OrbMazeLeft = listOf(
|
|
|
|
|
"############",
|
|
|
|
|
"#o.........#",
|
|
|
|
@@ -134,7 +134,7 @@ internal data class OrbGame(
|
|
|
|
|
if (moved.pos in powers) {
|
|
|
|
|
powers = powers - moved.pos; score += 50; events += OrbEvent.Power
|
|
|
|
|
powerLeft = powerTicks; chain = 0
|
|
|
|
|
// The rocks take fright and turn about.
|
|
|
|
|
// The cast take fright and turn about.
|
|
|
|
|
chasers = chasers.map { c -> if (c.returning || !c.out) c else c.copy(scared = true, mover = c.mover.copy(dir = c.mover.dir.opposite)) }
|
|
|
|
|
}
|
|
|
|
|
g = g.copy(player = moved, stars = stars, powers = powers, score = score, chasers = chasers, powerLeft = powerLeft, chain = chain)
|
|
|
|
@@ -197,13 +197,13 @@ internal data class OrbGame(
|
|
|
|
|
private fun chaseTarget(index: Int, c: OrbChaser): OrbPos {
|
|
|
|
|
val p = player.pos; val d = player.dir
|
|
|
|
|
return when (index) {
|
|
|
|
|
// Straight for Orb-Man.
|
|
|
|
|
// Blaze: straight for Orb-Man.
|
|
|
|
|
0 -> p
|
|
|
|
|
// Cuts in three squares ahead of him.
|
|
|
|
|
// Zip: cuts in three squares ahead of him.
|
|
|
|
|
1 -> OrbPos(p.x + 3 * d.dx, p.y + 3 * d.dy)
|
|
|
|
|
// Hunts him close up, and drifts back to its corner when he's far away.
|
|
|
|
|
// Drift: hunts him close up, and floats back to its corner when he's far away.
|
|
|
|
|
2 -> if (abs(c.mover.pos.x - p.x) + abs(c.mover.pos.y - p.y) > 9) OrbPos(maze.width - 2, maze.height - 2) else p
|
|
|
|
|
// Guards the stars nearest to him.
|
|
|
|
|
// Luna: guards the stars nearest to him.
|
|
|
|
|
else -> stars.minByOrNull { abs(it.x - p.x) + abs(it.y - p.y) } ?: p
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -226,7 +226,6 @@ internal data class OrbGame(
|
|
|
|
|
|
|
|
|
|
private val Marquee = FontFamily(Font(R.font.anton_regular))
|
|
|
|
|
private val Honey = Color(0xFFFFD84A)
|
|
|
|
|
internal val OrbChaserColours = listOf(Color(0xFFFF4FA3), Color(0xFF35D6F2), Color(0xFFFF8A3D), Color(0xFFA77BFF))
|
|
|
|
|
private val OrbWall = Color(0xFF2E4FE0)
|
|
|
|
|
private val OrbWallLight = Color(0xFF7D95FF)
|
|
|
|
|
private val OrbFloor = Color(0xFF0A1850)
|
|
|
|
@@ -253,39 +252,87 @@ internal fun DrawScope.drawOrbMascot(centre: Offset, r: Float, dir: OrbDir = Orb
|
|
|
|
|
drawArc(Outline, 0f, 180f, false, ringTop - Offset(0f, -r * .1f), Size(ringW, ringH), style = Stroke(r * .05f))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** A space rock: lumpy, with eyes that follow its way. Frightened it turns pale and wobbles; caught, only its eyes go home. */
|
|
|
|
|
internal fun DrawScope.drawOrbChaser(centre: Offset, r: Float, colour: Color, dir: OrbDir, scared: Boolean, returning: Boolean, blink: Boolean, wobble: Float) {
|
|
|
|
|
/**
|
|
|
|
|
* Orb-Man's cast (Paul, 5 November 2026: "our own mascots, part of the system itself"). Four of Orbit's sky characters, each with
|
|
|
|
|
* its own look and its own way of giving chase, in the order [OrbGame] hunts with them.
|
|
|
|
|
*/
|
|
|
|
|
internal enum class OrbCharacter(val title: String, val colour: Color, val line: String) {
|
|
|
|
|
Blaze("Blaze", Color(0xFFFF8A3D), "A hot-headed comet: comes straight for you"),
|
|
|
|
|
Zip("Zip", Color(0xFFFF4FA3), "A shooting star: cuts in ahead of you"),
|
|
|
|
|
Drift("Drift", Color(0xFF35D6F2), "A sleepy nebula: close up it chases, far off it floats home"),
|
|
|
|
|
Luna("Luna", Color(0xFFA77BFF), "A little moon: guards the stars nearest you")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal val OrbChaserColours = OrbCharacter.entries.map { it.colour }
|
|
|
|
|
|
|
|
|
|
private fun starPath(centre: Offset, outer: Float, inner: Float, turn: Float) = Path().apply {
|
|
|
|
|
for (k in 0 until 10) {
|
|
|
|
|
val a = -PI / 2 + k * PI / 5 + turn
|
|
|
|
|
val rad = if (k % 2 == 0) outer else inner
|
|
|
|
|
val x = centre.x + (rad * kotlin.math.cos(a)).toFloat(); val y = centre.y + (rad * sin(a)).toFloat()
|
|
|
|
|
if (k == 0) moveTo(x, y) else lineTo(x, y)
|
|
|
|
|
}
|
|
|
|
|
close()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* One of the cast, with eyes that follow its way. Frightened, each keeps its shape but turns pale and worried, blinking white as
|
|
|
|
|
* the power wears off; caught, only its eyes hurry home.
|
|
|
|
|
*/
|
|
|
|
|
internal fun DrawScope.drawOrbChaser(centre: Offset, r: Float, who: OrbCharacter, dir: OrbDir, scared: Boolean, returning: Boolean, blink: Boolean, wobble: Float) {
|
|
|
|
|
if (!returning) {
|
|
|
|
|
val body = if (scared) (if (blink) Color(0xFFE8F0FF) else Color(0xFF4D6BFF)) else colour
|
|
|
|
|
val rock = Path().apply {
|
|
|
|
|
val n = 9
|
|
|
|
|
for (i in 0..n) {
|
|
|
|
|
val a = 2 * PI * i / n
|
|
|
|
|
val bump = 1f + .12f * sin(a * 3 + wobble).toFloat()
|
|
|
|
|
val x = centre.x + (r * bump * kotlin.math.cos(a)).toFloat(); val y = centre.y + (r * bump * sin(a)).toFloat()
|
|
|
|
|
if (i == 0) moveTo(x, y) else lineTo(x, y)
|
|
|
|
|
val body = if (scared) (if (blink) Color(0xFFE8F0FF) else Color(0xFF4D6BFF)) else who.colour
|
|
|
|
|
when (who) {
|
|
|
|
|
OrbCharacter.Blaze -> {
|
|
|
|
|
// Its flame trails behind it, flickering.
|
|
|
|
|
if (!scared) for (k in 3 downTo 1) {
|
|
|
|
|
val back = Offset(-dir.dx * r * .55f * k, -dir.dy * r * .55f * k)
|
|
|
|
|
val flick = 1f + .12f * sin(wobble * 2 + k).toFloat()
|
|
|
|
|
drawCircle((if (k == 1) Color(0xFFFFC23D) else Color(0xFFFFE066)).copy(alpha = if (k == 1) 1f else .85f / k), r * (.75f - .15f * k) * flick, centre + back)
|
|
|
|
|
}
|
|
|
|
|
drawCircle(body, r * .95f, centre)
|
|
|
|
|
drawCircle(Color.White.copy(alpha = .22f), r * .3f, centre + Offset(-r * .35f, -r * .4f))
|
|
|
|
|
}
|
|
|
|
|
OrbCharacter.Zip -> {
|
|
|
|
|
drawPath(starPath(centre, r * 1.12f, r * .6f, .08f * sin(wobble).toFloat()), body)
|
|
|
|
|
drawCircle(body, r * .62f, centre)
|
|
|
|
|
}
|
|
|
|
|
OrbCharacter.Drift -> {
|
|
|
|
|
// A soft puff of cloud that breathes.
|
|
|
|
|
val puff = 1f + .05f * sin(wobble).toFloat()
|
|
|
|
|
listOf(Offset(0f, .12f) to .72f, Offset(-.52f, .22f) to .48f, Offset(.52f, .22f) to .48f, Offset(-.22f, -.32f) to .5f, Offset(.3f, -.26f) to .46f)
|
|
|
|
|
.forEach { (o, size) -> drawCircle(body, r * size * puff, centre + Offset(o.x * r, o.y * r)) }
|
|
|
|
|
}
|
|
|
|
|
OrbCharacter.Luna -> {
|
|
|
|
|
drawCircle(body, r * .95f, centre)
|
|
|
|
|
if (!scared) for ((o, size) in listOf(Offset(.4f, .35f) to .17f, Offset(-.45f, .4f) to .12f, Offset(.5f, -.45f) to .1f))
|
|
|
|
|
drawCircle(Color.Black.copy(alpha = .16f), r * size, centre + Offset(o.x * r, o.y * r))
|
|
|
|
|
drawCircle(Color.White.copy(alpha = .2f), r * .28f, centre + Offset(-r * .38f, -r * .42f))
|
|
|
|
|
}
|
|
|
|
|
close()
|
|
|
|
|
}
|
|
|
|
|
drawPath(rock, body)
|
|
|
|
|
drawCircle(Color.White.copy(alpha = .18f), r * .3f, centre + Offset(-r * .35f, -r * .4f))
|
|
|
|
|
drawCircle(Color.Black.copy(alpha = .12f), r * .18f, centre + Offset(r * .4f, r * .35f))
|
|
|
|
|
if (scared) {
|
|
|
|
|
// A worried wavy mouth instead of eyes that hunt.
|
|
|
|
|
val ink = if (blink) Color(0xFF4D6BFF) else Color.White
|
|
|
|
|
val w = r * .9f; val y = centre.y + r * .3f
|
|
|
|
|
val p = Path().apply { moveTo(centre.x - w / 2, y); for (k in 1..4) lineTo(centre.x - w / 2 + k * w / 4, y + if (k % 2 == 1) -r * .14f else 0f) }
|
|
|
|
|
drawPath(p, if (blink) Color(0xFF4D6BFF) else Color.White, style = Stroke(r * .1f))
|
|
|
|
|
drawCircle(if (blink) Color(0xFF4D6BFF) else Color.White, r * .1f, centre + Offset(-r * .3f, -r * .15f))
|
|
|
|
|
drawCircle(if (blink) Color(0xFF4D6BFF) else Color.White, r * .1f, centre + Offset(r * .3f, -r * .15f))
|
|
|
|
|
drawPath(p, ink, style = Stroke(r * .1f))
|
|
|
|
|
drawCircle(ink, r * .1f, centre + Offset(-r * .3f, -r * .15f))
|
|
|
|
|
drawCircle(ink, r * .1f, centre + Offset(r * .3f, -r * .15f))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val look = Offset(dir.dx * r * .14f, dir.dy * r * .14f)
|
|
|
|
|
for (side in listOf(-1f, 1f)) {
|
|
|
|
|
val eye = centre + Offset(side * r * .36f, -r * .12f)
|
|
|
|
|
drawCircle(Color.White, r * .27f, eye)
|
|
|
|
|
val eye = centre + Offset(side * r * .34f, -r * .1f)
|
|
|
|
|
drawCircle(Color.White, r * .26f, eye)
|
|
|
|
|
drawCircle(Color(0xFF14213D), r * .13f, eye + look)
|
|
|
|
|
}
|
|
|
|
|
// Luna's sleepy lids, Blaze's cross brows: a little character each.
|
|
|
|
|
if (!returning) when (who) {
|
|
|
|
|
OrbCharacter.Blaze -> for (side in listOf(-1f, 1f)) drawLine(Color(0xFF14213D), centre + Offset(side * r * .58f, -r * .48f), centre + Offset(side * r * .14f, -r * .32f), r * .1f, StrokeCap.Round)
|
|
|
|
|
OrbCharacter.Luna -> for (side in listOf(-1f, 1f)) drawArc(who.colour, 180f, 180f, true, centre + Offset(side * r * .34f - r * .27f, -r * .37f), Size(r * .54f, r * .5f))
|
|
|
|
|
else -> {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** The maze and everyone in it. [phase] is how far between ticks we are, for smooth movement; [glow] the power glow, 0 to 1. */
|
|
|
|
@@ -330,7 +377,7 @@ internal fun DrawScope.drawOrbField(game: OrbGame, phase: Float = 0f, glow: Floa
|
|
|
|
|
val blinking = game.powered && game.powerLeft < 100 && (game.powerLeft / 12) % 2 == 0
|
|
|
|
|
game.chasers.forEachIndexed { i, c ->
|
|
|
|
|
val every = when { c.returning -> 4; c.scared -> game.chaserEvery + 6; !c.out -> game.chaserEvery + 4; else -> game.chaserEvery }
|
|
|
|
|
drawOrbChaser(drawn(c.mover, every), cell * .42f, OrbChaserColours[i], c.mover.dir, c.scared, c.returning, blinking, timeMs / 140f + i)
|
|
|
|
|
drawOrbChaser(drawn(c.mover, every), cell * .42f, OrbCharacter.entries[i], c.mover.dir, c.scared, c.returning, blinking, timeMs / 140f + i)
|
|
|
|
|
}
|
|
|
|
|
val chomp = if (game.readyLeft > 0) 0f else (.5f + .5f * sin(timeMs / 70.0).toFloat())
|
|
|
|
|
drawOrbMascot(drawn(game.player, game.playerEvery), cell * .38f, game.player.dir, chomp)
|
|
|
|
@@ -429,6 +476,14 @@ internal fun OrbManScreen(best: Int, onBest: (Int) -> Unit, onLeave: () -> Unit)
|
|
|
|
|
Text(maxOf(best, game.score).toString(), color = Color.White, fontFamily = Marquee, fontSize = 32.sp)
|
|
|
|
|
Text("LEVEL ${game.level}", color = Muted, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 2.sp)
|
|
|
|
|
Canvas(Modifier.height(30.dp).fillMaxWidth()) { repeat(game.lives) { drawOrbMascot(Offset(16f + it * 44f, size.height / 2), 11f) } }
|
|
|
|
|
Spacer(Modifier.height(8.dp))
|
|
|
|
|
Text("THE CAST", color = Muted, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 2.sp)
|
|
|
|
|
OrbCharacter.entries.forEach { who ->
|
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
|
|
|
|
Canvas(Modifier.size(22.dp)) { drawOrbChaser(center, size.minDimension * .4f, who, OrbDir.Right, false, false, false, 0f) }
|
|
|
|
|
Text(who.title, color = who.colour, fontSize = 14.sp, fontWeight = FontWeight.SemiBold)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Spacer(Modifier.weight(1f))
|
|
|
|
|
Text("◄►▲▼ Steer", color = Muted, fontSize = 13.sp)
|
|
|
|
|
Text("OK or Back Pause", color = Muted, fontSize = 13.sp)
|
|
|
|
|