The Orbit sound kit (0.120.0, versionCode 311): 28 gentle SoundCraft effects, wired into every Arcade game
- design/arcade/sounds: each sound a SoundCraft session (editable .scraft kept), soft sine and triangle patches, filtered and levelled, delivered as small mono Ogg (133 KB for the kit) - ArcadeSfx: the kit, each sound's level, most-at-once, gap and priority; SfxLimiter (the oldest gives way); ArcadeAudio.sfx() reads the settings at most every 250 ms, so playing allocates nothing - Originals: Orbi-Raiders (new boss-hit and damaged events), Orbiteroids, Channel Chaos, Orbit Rush, Night Shift, Test Card Tangle, Codebreaker, Quiz Night - Classics: Block Drop, Blast Off, Skydoku, Comet Trail, Brick Break, Pairs, Patience (GameSounds hears each change of the game's value) - A Sound effects setting for every game; Effects, Mute, Orbit Quiet and Wind Down still apply - SoundKitTest: files present and small, lists cover the kit, caps and gaps, 0 bytes allocated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import tv.orbit.classic.arcade.GameSounds
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import tv.orbit.classic.arcade.ArcadeColours
|
||||
import tv.orbit.classic.arcade.ArcadeGames
|
||||
import tv.orbit.classic.arcade.ArcadeKey
|
||||
@@ -258,6 +260,18 @@ internal fun BlastOffScreen(play: ArcadePlay) {
|
||||
if (howTo) HowToPlayCard(gameDef, firstRun = false, everyTime = null, onEveryTime = {}, onPlay = { howTo = false }, onBack = { howTo = false })
|
||||
return
|
||||
}
|
||||
// The Orbit sound kit: a soft knock as a shape goes down, a sweep and chime for cleared lines, a tick as it moves.
|
||||
val soundsOn = remember { play.setting("sounds") }
|
||||
GameSounds(game) { was, now ->
|
||||
if (stage != ClassicStage.Play || now.score < was.score) return@GameSounds // a new board: nothing to hear
|
||||
val audio = latestPlay.audio
|
||||
when {
|
||||
now.board !== was.board && now.lastCleared > 0 -> audio.sfx(Sfx.LINE, soundsOn)
|
||||
now.board !== was.board -> audio.sfx(Sfx.PLACE, soundsOn)
|
||||
now.x != was.x || now.y != was.y || now.selected != was.selected || now.inTray != was.inTray -> audio.sfx(Sfx.MOVE, soundsOn)
|
||||
}
|
||||
if (was.alive && !now.alive) audio.sfx(if (!challenge && now.score > bestBefore) Sfx.NEW_BEST else Sfx.GAME_OVER, soundsOn)
|
||||
}
|
||||
val keys = Modifier.focusRequester(focus).focusable().gameKeys(enabled = stage == ClassicStage.Play && !paused,
|
||||
// Back by context: choosing in the tray, Back goes back to the board with the shape you had; on the board it pauses.
|
||||
active = { game.inTray }, cancel = { setGame(game.move(0, -1)) }, pause = ::pause) { key, native ->
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import tv.orbit.classic.arcade.GameSounds
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import tv.orbit.classic.arcade.ArcadeColours
|
||||
import tv.orbit.classic.arcade.ArcadeGames
|
||||
import tv.orbit.classic.arcade.ArcadeKey
|
||||
@@ -356,6 +358,21 @@ internal fun BlockDropScreen(play: ArcadePlay) {
|
||||
if (howTo) HowToPlayCard(gameDef, firstRun = false, everyTime = null, onEveryTime = {}, onPlay = { howTo = false }, onBack = { howTo = false })
|
||||
return
|
||||
}
|
||||
// The Orbit sound kit: a soft knock as a piece lands, a click as it turns, a sweep and chime for cleared rows.
|
||||
val soundsOn = remember { play.setting("sounds") }
|
||||
GameSounds(game) { was, now ->
|
||||
// A new game in place of the old (fewer rows or points) isn't a move: nothing to hear.
|
||||
if (stage != ClassicStage.Play || now.lines < was.lines || now.score < was.score) return@GameSounds
|
||||
val audio = latestPlay.audio
|
||||
when {
|
||||
now.lines > was.lines -> audio.sfx(Sfx.LINE, soundsOn)
|
||||
now.bag !== was.bag -> audio.sfx(Sfx.PLACE, soundsOn)
|
||||
now.piece.turns != was.piece.turns -> audio.sfx(Sfx.TURN, soundsOn)
|
||||
}
|
||||
if (now.powers > was.powers) audio.sfx(Sfx.POWER, soundsOn)
|
||||
if (now.fades > was.fades) audio.sfx(Sfx.FADE, soundsOn)
|
||||
if (was.alive && !now.alive) audio.sfx(if (now.score > bestBefore && !sprint) Sfx.NEW_BEST else Sfx.GAME_OVER, soundsOn)
|
||||
}
|
||||
val keys = Modifier.focusRequester(focus).focusable().gameKeys(enabled = stage == ClassicStage.Play && !paused, pause = ::pause) { key, native ->
|
||||
// Releases are always noted, so the guard knows a key was let go even if the game paused meanwhile.
|
||||
if (native.action == KeyEvent.ACTION_UP) { guard.accept(native); return@gameKeys false }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import tv.orbit.classic.arcade.ArcadeColours
|
||||
import tv.orbit.classic.arcade.ArcadeGames
|
||||
import tv.orbit.classic.arcade.ArcadeKey
|
||||
@@ -295,7 +296,17 @@ internal fun BrickBreakScreen(play: ArcadePlay) {
|
||||
ArcadeGameLoop(loopRuns(paused, game.alive && stage == ClassicStage.Play, shown = true)) { _, dt ->
|
||||
if (paused || !game.alive || stage != ClassicStage.Play) return@ArcadeGameLoop
|
||||
// Difficulty runs the whole wall a little slower or quicker; Normal is as it always was.
|
||||
val was = game
|
||||
game = game.step((dt / 1e9f).coerceAtMost(.05f) * pace, held)
|
||||
// The Orbit sound kit: a pop for a brick, a soft knock off the paddle, a bonk for a lost Luna, a chime for a wall cleared.
|
||||
val audio = latestPlay.audio
|
||||
when {
|
||||
!game.alive -> audio.sfx(if (game.score > bestBefore) Sfx.NEW_BEST else Sfx.GAME_OVER, soundsOn)
|
||||
game.level > was.level -> audio.sfx(Sfx.LEVEL_CLEAR, soundsOn)
|
||||
game.lives < was.lives -> audio.sfx(Sfx.PLAYER_HIT, soundsOn)
|
||||
game.bricks.size < was.bricks.size -> audio.sfx(Sfx.HIT, soundsOn)
|
||||
was.vy > 0f && game.vy < 0f && game.launched -> audio.sfx(Sfx.PLACE, soundsOn, .8f)
|
||||
}
|
||||
if (game.sounds.isNotEmpty()) { game.sounds.forEach { power -> BrickPowerSounds[power]?.let { latestPlay.audio.cue(it, .7f, soundsOn) } }; game = game.copy(sounds = emptyList()) }
|
||||
if (!game.alive) { held = 0; run.end(RunEnd(game.score, finished = true, detail = "Wall ${game.level}")); stage = ClassicStage.Result }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import tv.orbit.classic.arcade.GameSounds
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import tv.orbit.classic.arcade.ArcadeColours
|
||||
import tv.orbit.classic.arcade.ArcadeGames
|
||||
import tv.orbit.classic.arcade.ArcadeKey
|
||||
@@ -288,6 +290,18 @@ internal fun PairsScreen(play: ArcadePlay) {
|
||||
if (howTo) HowToPlayCard(gameDef, firstRun = false, everyTime = null, onEveryTime = {}, onPlay = { howTo = false }, onBack = { howTo = false })
|
||||
return
|
||||
}
|
||||
// The Orbit sound kit: a soft flick as a card turns, a chime for a pair, a tick as the cursor moves.
|
||||
val soundsOn = remember { play.setting("sounds") }
|
||||
GameSounds(game) { was, now ->
|
||||
if (stage != ClassicStage.Play || now.cards !== was.cards) return@GameSounds // a new board: nothing to hear
|
||||
val audio = latestPlay.audio
|
||||
when {
|
||||
now.done && !was.done -> audio.sfx(Sfx.LEVEL_CLEAR, soundsOn)
|
||||
now.matched.size > was.matched.size -> audio.sfx(Sfx.MATCH, soundsOn)
|
||||
now.open.size != was.open.size -> audio.sfx(Sfx.CARD, soundsOn)
|
||||
now.cursor != was.cursor -> audio.sfx(Sfx.MOVE, soundsOn)
|
||||
}
|
||||
}
|
||||
val keys = Modifier.focusRequester(focus).focusable().gameKeys(enabled = stage == ClassicStage.Play && !paused, pause = { paused = true }) { key, native ->
|
||||
if (native.action != KeyEvent.ACTION_DOWN || game.done) return@gameKeys key != ArcadeKey.Other
|
||||
var next = when (key) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import tv.orbit.classic.arcade.GameSounds
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import android.view.KeyEvent
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.Canvas
|
||||
@@ -315,6 +317,24 @@ internal fun PatienceScreen(play: ArcadePlay) {
|
||||
if (howTo) HowToPlayCard(gameDef, firstRun = false, everyTime = null, onEveryTime = {}, onPlay = { howTo = false }, onBack = { howTo = false })
|
||||
return
|
||||
}
|
||||
// The Orbit sound kit: a flick for a card turned from the stock, a lift and a soft knock for a move, a chime for a card
|
||||
// home, two soft taps when it can't go there.
|
||||
val soundsOn = remember { play.setting("sounds") }
|
||||
GameSounds(game) { was, now ->
|
||||
if (stage != ClassicStage.Play || (now.moves == 0 && was.moves != 0)) return@GameSounds // a new deal: nothing to hear
|
||||
val audio = latestPlay.audio
|
||||
val home = { g: PatienceGame -> HOMES.sumOf { g.piles[it].size } }
|
||||
when {
|
||||
now.won && !was.won -> audio.sfx(Sfx.LEVEL_CLEAR, soundsOn)
|
||||
now.moves < was.moves -> audio.sfx(Sfx.BACK, soundsOn) // Undo
|
||||
now.refusals > was.refusals -> audio.sfx(Sfx.NOPE, soundsOn)
|
||||
home(now) > home(was) -> audio.sfx(Sfx.MATCH, soundsOn)
|
||||
now.moves > was.moves -> audio.sfx(Sfx.PLACE, soundsOn)
|
||||
now.piles[STOCK].size != was.piles[STOCK].size -> audio.sfx(Sfx.CARD, soundsOn)
|
||||
now.held != was.held -> audio.sfx(Sfx.TURN, soundsOn)
|
||||
now.pile != was.pile -> audio.sfx(Sfx.MOVE, soundsOn)
|
||||
}
|
||||
}
|
||||
val keys = Modifier.focusRequester(focus).focusable().gameKeys(enabled = stage == ClassicStage.Play && !paused,
|
||||
// Back by context: a held card goes back first; with nothing held, Back pauses.
|
||||
active = { game.held != null }, cancel = { game = game.drop() }, pause = { paused = true }) { key, native ->
|
||||
|
||||
@@ -13,6 +13,8 @@ import tv.orbit.classic.arcade.HowToPlayCard
|
||||
import tv.orbit.classic.arcade.HudLabel
|
||||
import tv.orbit.classic.arcade.HudValue
|
||||
import tv.orbit.classic.arcade.Mascot
|
||||
import tv.orbit.classic.arcade.GameSounds
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import tv.orbit.classic.arcade.gameKeys
|
||||
import kotlinx.coroutines.launch
|
||||
import tv.orbit.classic.arcade.SKY_CHALLENGE_SCORES
|
||||
@@ -320,6 +322,20 @@ internal fun SkydokuScreen(play: ArcadePlay) {
|
||||
if (howTo) HowToPlayCard(gameDef, firstRun = false, everyTime = null, onEveryTime = {}, onPlay = { howTo = false }, onBack = { howTo = false })
|
||||
return
|
||||
}
|
||||
// The Orbit sound kit: a soft bell for each of the cast placed, two soft taps for a wrong square, a chime when it's solved.
|
||||
val soundsOn = remember { play.setting("sounds") }
|
||||
GameSounds(g) { was, now ->
|
||||
if (stage != ClassicStage.Play || now.puzzle !== was.puzzle) return@GameSounds // a new puzzle: nothing to hear
|
||||
val audio = latestPlay.audio
|
||||
when {
|
||||
now.done && !was.done -> audio.sfx(Sfx.LEVEL_CLEAR, soundsOn)
|
||||
now.out && !was.out -> audio.sfx(Sfx.GAME_OVER, soundsOn)
|
||||
now.hearts < was.hearts -> audio.sfx(Sfx.NOPE, soundsOn)
|
||||
now.placed.size > was.placed.size -> audio.sfx(Sfx.LIGHT, soundsOn)
|
||||
now.crossed.size != was.crossed.size -> audio.sfx(Sfx.TURN, soundsOn)
|
||||
now.cursor != was.cursor -> audio.sfx(Sfx.MOVE, soundsOn)
|
||||
}
|
||||
}
|
||||
val keys = Modifier.focusRequester(focus).focusable().gameKeys(enabled = stage == ClassicStage.Play && !paused && g != null, pause = { paused = true }) { key, native ->
|
||||
val cur = game ?: return@gameKeys false
|
||||
if (native.action != KeyEvent.ACTION_DOWN || cur.done || cur.out) return@gameKeys key != ArcadeKey.Other
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import tv.orbit.classic.arcade.GameSounds
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import tv.orbit.classic.arcade.ArcadeColours
|
||||
import tv.orbit.classic.arcade.ArcadeGames
|
||||
import tv.orbit.classic.arcade.ArcadeKey
|
||||
@@ -276,6 +278,17 @@ internal fun SnakeScreen(play: ArcadePlay) {
|
||||
var musicOn by remember { mutableStateOf(play.setting("music")) }
|
||||
val playing = musicOn && !paused && game.alive && stage == ClassicStage.Play
|
||||
LaunchedEffect(playing) { play.audio.music(R.raw.snake_theme, playing, base = .5f, gameOn = musicOn) }
|
||||
// The Orbit sound kit, beside the music: a ping for each star, a chime for a constellation lit.
|
||||
val soundsOn = remember { play.setting("sounds") }
|
||||
GameSounds(game) { was, now ->
|
||||
if (stage != ClassicStage.Play || now.score < was.score) return@GameSounds // a new game: nothing to hear
|
||||
val audio = latestPlay.audio
|
||||
when {
|
||||
was.alive && !now.alive -> audio.sfx(if (now.score > bestBefore) Sfx.NEW_BEST else Sfx.GAME_OVER, soundsOn)
|
||||
now.lit > was.lit -> audio.sfx(Sfx.LEVEL_CLEAR, soundsOn)
|
||||
now.score > was.score -> audio.sfx(Sfx.STAR, soundsOn)
|
||||
}
|
||||
}
|
||||
DisposableEffect(Unit) { onDispose { play.audio.stopMusic() } }
|
||||
LaunchedEffect(stage, paused) { if (stage == ClassicStage.Play && !paused) runCatching { focus.requestFocus() } }
|
||||
// Luna names each constellation as it lights up, for a moment.
|
||||
|
||||
@@ -53,6 +53,12 @@ internal class ArcadeAudio(private val context: Context, private val prefs: () -
|
||||
private var musicBase = .5f
|
||||
private var released = false
|
||||
|
||||
private val kitIds = IntArray(Sfx.COUNT)
|
||||
private val limiter = SfxLimiter()
|
||||
/** The profile's effects level and Orbit's ceiling, read at most every quarter second (so a busy loop reads no settings). */
|
||||
private var kitScale = 0f
|
||||
private var kitScaleAt = Long.MIN_VALUE / 2
|
||||
|
||||
fun ceiling(): Float = arcadeCeiling(identQuietNow(settings), OrbitQuiet.windDown)
|
||||
fun effects(base: Float, gameOn: Boolean = true) = effectsLevel(base, prefs(), gameOn, ceiling())
|
||||
fun music(base: Float, gameOn: Boolean = true) = musicLevel(base, prefs(), gameOn, ceiling())
|
||||
@@ -60,7 +66,7 @@ internal class ArcadeAudio(private val context: Context, private val prefs: () -
|
||||
private fun pool(): SoundPool? {
|
||||
if (released) return null
|
||||
return pool ?: runCatching {
|
||||
SoundPool.Builder().setMaxStreams(4).setAudioAttributes(AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_GAME)
|
||||
SoundPool.Builder().setMaxStreams(8).setAudioAttributes(AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_GAME)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build()).build()
|
||||
}.getOrNull().also { pool = it }
|
||||
}
|
||||
@@ -77,6 +83,35 @@ internal class ArcadeAudio(private val context: Context, private val prefs: () -
|
||||
runCatching { p.play(id, level, level, 1, 0, 1f) }
|
||||
}
|
||||
|
||||
/** Loads the whole Orbit sound kit, once; it's small (about 180 KB) and every game shares it. */
|
||||
fun preloadKit() {
|
||||
val p = pool() ?: return
|
||||
for (s in 0 until Sfx.COUNT) if (kitIds[s] == 0) kitIds[s] = runCatching { p.load(context, Sfx.raw[s], 1) }.getOrDefault(0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays one of the Orbit sound kit ([Sfx]) at its own level times [scale]; nothing when this game's effects are off
|
||||
* ([gameOn]), the profile's Effects or Mute say so, or it's inside its gap. Orbit Quiet and Wind Down are the ceiling.
|
||||
* Nothing is made: safe to call from a game loop.
|
||||
*/
|
||||
fun sfx(sound: Int, gameOn: Boolean = true, scale: Float = 1f, rate: Float = 1f) {
|
||||
if (!gameOn || released || sound !in 0 until Sfx.COUNT) return
|
||||
val now = android.os.SystemClock.uptimeMillis()
|
||||
if (now - kitScaleAt > 250) { kitScale = effects(1f); kitScaleAt = now }
|
||||
val level = (Sfx.level[sound] * scale * kitScale).coerceIn(0f, 1f)
|
||||
if (level <= 0f) return
|
||||
val p = pool() ?: return
|
||||
if (kitIds[sound] == 0) { preloadKit(); return }
|
||||
val slot = limiter.admit(sound, now)
|
||||
if (slot < 0) return
|
||||
val old = limiter.streams[slot]
|
||||
// try, not runCatching: a Result would box the stream number, and this runs in game loops.
|
||||
limiter.streams[slot] = try {
|
||||
if (old != 0) p.stop(old)
|
||||
p.play(kitIds[sound], level, level, Sfx.priority[sound], 0, rate.coerceIn(.5f, 2f))
|
||||
} catch (_: RuntimeException) { 0 }
|
||||
}
|
||||
|
||||
/** Loads sound files ahead (BumbleHive's tones, written once into the cache). */
|
||||
fun preloadFiles(vararg paths: String) { val p = pool() ?: return; paths.forEach { f -> if (f !in fileSounds) fileSounds[f] = p.load(f, 1) } }
|
||||
|
||||
@@ -114,6 +149,6 @@ internal class ArcadeAudio(private val context: Context, private val prefs: () -
|
||||
released = true
|
||||
runCatching { player?.release() }; player = null
|
||||
runCatching { pool?.release() }; pool = null
|
||||
sounds.clear(); fileSounds.clear()
|
||||
sounds.clear(); fileSounds.clear(); kitIds.fill(0); limiter.clear()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ internal object ArcadeGames {
|
||||
// Playable from 9 November 2026: tv.orbit.classic.arcade.nightshift. Its High Scores keep the stars won across the chapters.
|
||||
val NightShift: ArcadeGame = GameDef("NightShift", "Nite Owl's Night Shift", "Route the starlight", "Turn the beams and guide each lost star home.", Mascot.NiteOwl,
|
||||
kidsSuitable = true, original = true, launchable = true, ScoreKind.Points, keepsLevels = true, legacyRecordKey = null,
|
||||
listOf(Control("◀▶▲▼", "Hop"), Control("OK", "Turn the beam"), BackPause), "Light the mast. No timer and no fail: just Nite Owl's par.") {
|
||||
listOf(Control("◀▶▲▼", "Hop"), Control("OK", "Turn the beam"), BackPause), "Light the mast. No timer and no fail: just Nite Owl's par.", listOf(GameSetting("sounds", "Sound effects"))) {
|
||||
tv.orbit.classic.arcade.nightshift.NightShiftScreen(it)
|
||||
}
|
||||
// Playable from 9 November 2026: tv.orbit.classic.arcade.orbiteroids (Scheme A, Paul's choice).
|
||||
@@ -100,19 +100,19 @@ internal object ArcadeGames {
|
||||
// The new Originals (approved 9 November 2026), first Quiz Night: tv.orbit.classic.arcade.quiz.
|
||||
val QuizNight: ArcadeGame = GameDef("QuizNight", "Quiz Night", "A family quiz, everyone at their level", "General knowledge, movies and TV, for one to four players.", Mascot.Ollie,
|
||||
kidsSuitable = true, original = true, launchable = true, ScoreKind.Points, keepsLevels = false, legacyRecordKey = null,
|
||||
listOf(Control("◀▶▲▼", "Choose an answer"), Control("OK", "Answer"), BackPause), "Each player answers at their own level; most right wins.") {
|
||||
listOf(Control("◀▶▲▼", "Choose an answer"), Control("OK", "Answer"), BackPause), "Each player answers at their own level; most right wins.", listOf(GameSetting("sounds", "Sound effects"))) {
|
||||
tv.orbit.classic.arcade.quiz.QuizNightScreen(it)
|
||||
}
|
||||
|
||||
val TestCardTangle: ArcadeGame = GameDef("TestCardTangle", "Test Card Tangle", "Turn the cables, bring the picture back", "Join every cable up to the signal and Orbit's test card comes back.", Mascot.Drift,
|
||||
kidsSuitable = true, original = true, launchable = true, ScoreKind.Points, keepsLevels = true, legacyRecordKey = null,
|
||||
listOf(Control("◀▶▲▼", "Move"), Control("OK", "Turn the piece"), BackPause), "Every piece joined to the signal, no loose ends. No timer.") {
|
||||
listOf(Control("◀▶▲▼", "Move"), Control("OK", "Turn the piece"), BackPause), "Every piece joined to the signal, no loose ends. No timer.", listOf(GameSetting("sounds", "Sound effects"))) {
|
||||
tv.orbit.classic.arcade.tangle.TestCardTangleScreen(it)
|
||||
}
|
||||
|
||||
val Codebreaker: ArcadeGame = GameDef("Codebreaker", "Orbi-Fax Codebreaker", "Crack the day's code on page 888", "A five-letter word in six tries, on Orbi-Fax's teletext.", Mascot.Luna,
|
||||
kidsSuitable = true, original = true, launchable = true, ScoreKind.Solved, keepsLevels = true, legacyRecordKey = null,
|
||||
listOf(Control("◀▶▲▼", "Choose a key"), Control("OK", "Type it"), Control("Back", "Delete a letter, or pause")), "Green: right place. Yellow: elsewhere in the word. Blue: not in it.") {
|
||||
listOf(Control("◀▶▲▼", "Choose a key"), Control("OK", "Type it"), Control("Back", "Delete a letter, or pause")), "Green: right place. Yellow: elsewhere in the word. Blue: not in it.", listOf(GameSetting("sounds", "Sound effects"))) {
|
||||
tv.orbit.classic.arcade.codebreaker.CodebreakerScreen(it)
|
||||
}
|
||||
|
||||
@@ -137,28 +137,28 @@ internal object ArcadeGames {
|
||||
listOf(GameSetting("sound", "Sound", legacyKey = "orb_man_sound"))) { OrbManScreen(it) }
|
||||
val Blast: ArcadeGame = GameDef("Blast", "Blast Off", "Fit the shapes, clear the lines", "Fit three shapes at a time; full rows and columns clear.", Mascot.Zip,
|
||||
kidsSuitable = false, original = false, launchable = true, ScoreKind.Points, keepsLevels = false, legacyRecordKey = "blast_best",
|
||||
listOf(Control("◀▶▲▼", "Move the shape"), Control("OK", "Place it"), Control("▼", "Off the board: choose another"), BackPause), "No room left for any shape and it's over.") { BlastOffScreen(it) }
|
||||
listOf(Control("◀▶▲▼", "Move the shape"), Control("OK", "Place it"), Control("▼", "Off the board: choose another"), BackPause), "No room left for any shape and it's over.", listOf(GameSetting("sounds", "Sound effects"))) { BlastOffScreen(it) }
|
||||
val Sky: ArcadeGame = GameDef("Sky", "Skydoku", "Find each of the cast a spot", "Put each of the cast in their colour: one per row and column, none touching.", Mascot.Luna,
|
||||
kidsSuitable = false, original = false, launchable = true, ScoreKind.Solved, keepsLevels = true, legacyRecordKey = "skydoku_solved",
|
||||
listOf(Control("◀▶▲▼", "Move"), Control("OK", "Place"), BackPause), "Three hearts, and a new puzzle every day.") { SkydokuScreen(it) }
|
||||
listOf(Control("◀▶▲▼", "Move"), Control("OK", "Place"), BackPause), "Three hearts, and a new puzzle every day.", listOf(GameSetting("sounds", "Sound effects"))) { SkydokuScreen(it) }
|
||||
val Snake: ArcadeGame = GameDef("Snake", "Comet Trail", "Snake, as Blaze's tail", "Help Blaze eat the stars. Each one grows his tail.", Mascot.Blaze,
|
||||
kidsSuitable = true, original = false, launchable = true, ScoreKind.Points, keepsLevels = false, legacyRecordKey = "snake_best",
|
||||
listOf(Control("◀▶▲▼", "Steer Blaze"), BackPause), "Don't hit the walls or your own trail.",
|
||||
listOf(GameSetting("music", "Music", legacyKey = "snake_music"))) { SnakeScreen(it) }
|
||||
listOf(GameSetting("music", "Music", legacyKey = "snake_music"), GameSetting("sounds", "Sound effects"))) { SnakeScreen(it) }
|
||||
val Blocks: ArcadeGame = GameDef("Blocks", "Block Drop", "Drift's stacking game", "Turn and drop the blocks, and clear full rows.", Mascot.Drift,
|
||||
kidsSuitable = true, original = false, launchable = true, ScoreKind.Points, keepsLevels = false, legacyRecordKey = "block_drop_best",
|
||||
listOf(Control("◀▶", "Move"), Control("▲", "Turn"), Control("▼", "Down"), Control("OK", "Drop"), BackPause), "Clear rows before the stack reaches the top.") { BlockDropScreen(it) }
|
||||
listOf(Control("◀▶", "Move"), Control("▲", "Turn"), Control("▼", "Down"), Control("OK", "Drop"), BackPause), "Clear rows before the stack reaches the top.", listOf(GameSetting("sounds", "Sound effects"))) { BlockDropScreen(it) }
|
||||
val Bricks: ArcadeGame = GameDef("Bricks", "Brick Break", "Luna is the ball", "Keep Luna in play and break every brick in the wall.", Mascot.Luna,
|
||||
kidsSuitable = true, original = false, launchable = true, ScoreKind.Points, keepsLevels = false, legacyRecordKey = "brick_break_best",
|
||||
listOf(Control("◀▶", "Hold to move"), Control("OK", "Launch"), BackPause), "Catch the gold stars for powers.",
|
||||
listOf(GameSetting("sounds", "Power sounds", legacyKey = "arcade_sounds"))) { BrickBreakScreen(it) }
|
||||
listOf(GameSetting("sounds", "Sound effects", legacyKey = "arcade_sounds"))) { BrickBreakScreen(it) }
|
||||
val Pairs: ArcadeGame = GameDef("Pairs", "Pairs", "Match the cast and the channels", "Find every pair of the cast and Orbit's channels.", Mascot.Ollie,
|
||||
kidsSuitable = true, original = false, launchable = true, ScoreKind.FewestMoves, keepsLevels = false, legacyRecordKey = "pairs_best",
|
||||
listOf(Control("◀▶▲▼", "Move"), Control("OK", "Turn a card"), BackPause), "In as few moves as you can.") { PairsScreen(it) }
|
||||
listOf(Control("◀▶▲▼", "Move"), Control("OK", "Turn a card"), BackPause), "In as few moves as you can.", listOf(GameSetting("sounds", "Sound effects"))) { PairsScreen(it) }
|
||||
val Patience: ArcadeGame = GameDef("Patience", "Patience", "Solitaire, with Ollie on every card", "Build each suit home from ace to king.", Mascot.Ollie,
|
||||
kidsSuitable = true, original = false, launchable = true, ScoreKind.Wins, keepsLevels = false, legacyRecordKey = "patience_wins",
|
||||
listOf(Control("◀▶▲▼", "Point"), Control("OK", "Pick up / put down"), Control("OK twice", "Send a card home"), Control("Back", "Put back, or pause")),
|
||||
"Klondike, one card at a time: build each suit home, ace to king.") { PatienceScreen(it) }
|
||||
"Klondike, one card at a time: build each suit home, ace to king.", listOf(GameSetting("sounds", "Sound effects"))) { PatienceScreen(it) }
|
||||
|
||||
val originals = listOf(OrbiRaiders, ChannelChaos, Hive, NightShift, Orbiteroids, QuizNight, TestCardTangle, Codebreaker, Daily, OrbitRush)
|
||||
val classics = listOf(OrbMan, Blast, Sky, Snake, Blocks, Bricks, Pairs, Patience)
|
||||
|
||||
@@ -132,7 +132,7 @@ internal fun OrbitArcade(modifier: Modifier, onPlaying: (Boolean) -> Unit, onExi
|
||||
SessionState.Exited -> LaunchedEffect(Unit) { playing = null }
|
||||
else -> {
|
||||
val audio = remember(game) { ArcadeAudio(context) { AudioPrefs.of(latestData.settings) } }
|
||||
DisposableEffect(audio) { onDispose { audio.release() } }
|
||||
DisposableEffect(audio) { audio.preloadKit(); onDispose { audio.release() } }
|
||||
val play = ArcadePlay(game.id, profile.id, bestOf(record, game.scoreKind), audio, record.level, record.levelsResetMs,
|
||||
readSetting = { key -> game.settings.firstOrNull { it.key == key }?.let { settingFor(latestData.game(game.id), it, repo::legacyFlag) } ?: true },
|
||||
writeSetting = { key, on -> update { d -> d.withGame(game.id) { it.copy(settings = it.settings + (key to on)) } } },
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package tv.orbit.classic.arcade
|
||||
|
||||
import tv.orbit.classic.R
|
||||
|
||||
/**
|
||||
* The Orbit sound kit (9 November 2026): one set of short, gentle effects shared by every Arcade game, so the library
|
||||
* sounds like one family. Made in SoundCraft (design/arcade/sounds/build-arcade-sounds.py keeps the editable sessions) and
|
||||
* delivered as small Ogg files, res/raw/sfx_*.ogg.
|
||||
*
|
||||
* Each sound has a number (so playing one is an array lookup, nothing made), its own level, how many of it may sound at
|
||||
* once (a busy wave can't stack up a wall of shots; the oldest one stops for the newest) and the shortest gap between two.
|
||||
*/
|
||||
internal object Sfx {
|
||||
const val FIRE = 0; const val HIT = 1; const val FADE = 2; const val BREAK = 3; const val BOSS_HIT = 4; const val BOSS_DOWN = 5
|
||||
const val PLAYER_HIT = 6; const val SHIELD = 7; const val POWER = 8; const val POWER_END = 9; const val LEVEL_CLEAR = 10
|
||||
const val NEW_BEST = 11; const val GAME_OVER = 12; const val PLACE = 13; const val LINE = 14; const val CARD = 15; const val MATCH = 16
|
||||
const val NOPE = 17; const val TURN = 18; const val LIGHT = 19; const val TICK = 20; const val MOVE = 21; const val SELECT = 22
|
||||
const val BACK = 23; const val STAR = 24; const val WHOOSH = 25; const val RISE = 26; const val DIVE = 27
|
||||
const val COUNT = 28
|
||||
/** The most of one sound at once, over the whole kit. */
|
||||
const val MAX_AT_ONCE = 3
|
||||
|
||||
val raw = intArrayOf(R.raw.sfx_fire, R.raw.sfx_hit, R.raw.sfx_fade, R.raw.sfx_break, R.raw.sfx_boss_hit, R.raw.sfx_boss_down,
|
||||
R.raw.sfx_player_hit, R.raw.sfx_shield, R.raw.sfx_power, R.raw.sfx_power_end, R.raw.sfx_level_clear,
|
||||
R.raw.sfx_new_best, R.raw.sfx_game_over, R.raw.sfx_place, R.raw.sfx_line, R.raw.sfx_card, R.raw.sfx_match,
|
||||
R.raw.sfx_nope, R.raw.sfx_turn, R.raw.sfx_light, R.raw.sfx_tick, R.raw.sfx_move, R.raw.sfx_select,
|
||||
R.raw.sfx_back, R.raw.sfx_star, R.raw.sfx_whoosh, R.raw.sfx_rise, R.raw.sfx_dive)
|
||||
|
||||
/** Each sound's level before the profile's settings and Orbit's quiet ceiling. The files are already mixed; these sit them together. */
|
||||
val level = floatArrayOf(.55f, .6f, .6f, .65f, .7f, .75f, .7f, .65f, .7f, .6f, .75f, .75f, .65f, .6f, .7f, .55f, .7f,
|
||||
.6f, .55f, .6f, .5f, .45f, .55f, .5f, .6f, .55f, .55f, .55f)
|
||||
|
||||
/** How many of each may sound at once (never more than [MAX_AT_ONCE]). */
|
||||
val atOnce = intArrayOf(3, 3, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 3, 2, 1, 1)
|
||||
|
||||
/** The shortest gap between two of one sound, in milliseconds: a held fire button or a burst of hits stays a patter, not a buzz. */
|
||||
val gapMs = intArrayOf(70, 45, 60, 50, 90, 400, 250, 200, 150, 150, 500, 500, 500, 40, 120, 35, 120, 150, 35, 50, 60, 30, 60, 60, 40, 80, 90, 90)
|
||||
|
||||
/** The big moments stay heard when the pool is full: a shot gives way first. */
|
||||
val priority = intArrayOf(0, 0, 0, 0, 1, 2, 2, 1, 1, 1, 2, 2, 2, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps each kit sound inside its limits: too soon after the last one and it's skipped; at its most-at-once, the oldest
|
||||
* still sounding gives way. Pure arrays and numbers, so playing a sound in a game loop makes nothing (checked by a test).
|
||||
*/
|
||||
internal class SfxLimiter {
|
||||
private val lastAt = LongArray(Sfx.COUNT) { Long.MIN_VALUE / 2 }
|
||||
private val next = IntArray(Sfx.COUNT)
|
||||
/** The streams sounding, [Sfx.MAX_AT_ONCE] places a sound; 0 is an empty place. */
|
||||
val streams = IntArray(Sfx.COUNT * Sfx.MAX_AT_ONCE)
|
||||
|
||||
/** The place for a new [sound] now, or -1 if it's too soon. Whatever stream is in that place should stop first. */
|
||||
fun admit(sound: Int, nowMs: Long): Int {
|
||||
if (sound !in 0 until Sfx.COUNT || nowMs - lastAt[sound] < Sfx.gapMs[sound]) return -1
|
||||
lastAt[sound] = nowMs
|
||||
val slot = sound * Sfx.MAX_AT_ONCE + next[sound]
|
||||
next[sound] = (next[sound] + 1) % Sfx.atOnce[sound].coerceIn(1, Sfx.MAX_AT_ONCE)
|
||||
return slot
|
||||
}
|
||||
|
||||
fun clear() { streams.fill(0); next.fill(0); lastAt.fill(Long.MIN_VALUE / 2) }
|
||||
}
|
||||
|
||||
/**
|
||||
* For the Classics, whose games are plain values replaced on each move: after each change of [state], [sounds] hears what it
|
||||
* was and what it is now, and plays what changed. A new game in place of the old one (Play Again) is heard too, so [sounds]
|
||||
* should only play for changes within one game. No game yet (null) is heard as nothing.
|
||||
*/
|
||||
@androidx.compose.runtime.Composable
|
||||
internal fun <T : Any> GameSounds(state: T?, sounds: (was: T, now: T) -> Unit) {
|
||||
val last = androidx.compose.runtime.remember { arrayOfNulls<Any>(1) }
|
||||
androidx.compose.runtime.SideEffect {
|
||||
@Suppress("UNCHECKED_CAST") val was = last[0] as T?
|
||||
last[0] = state
|
||||
if (was != null && state != null && was !== state) sounds(was, state)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package tv.orbit.classic.arcade.chaos
|
||||
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import android.view.KeyEvent
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.Canvas
|
||||
@@ -126,7 +127,6 @@ internal fun ChannelChaosScreen(play: ArcadePlay) {
|
||||
val measurer = rememberTextMeasurer()
|
||||
val art = remember(density) { ChaosArt(density, measurer) }
|
||||
val logo = ImageBitmapCache.orbitLogo()
|
||||
LaunchedEffect(Unit) { play.audio.preload(R.raw.power_drift_net, R.raw.power_wide_orbit) }
|
||||
|
||||
fun startRun() {
|
||||
bestBefore = maxOf(latestPlay.best, bestSeen)
|
||||
@@ -147,8 +147,16 @@ internal fun ChannelChaosScreen(play: ArcadePlay) {
|
||||
val ev = sim.takeEvents()
|
||||
if (ev != 0) {
|
||||
val audio = latestPlay.audio
|
||||
if (ev and (ChaosEvents.POWER or ChaosEvents.BONUS) != 0) audio.cue(R.raw.power_drift_net, .6f, soundsOn)
|
||||
if (ev and (ChaosEvents.STAGE or ChaosEvents.REPAIRED) != 0) audio.cue(R.raw.power_wide_orbit, .6f, soundsOn)
|
||||
// The Orbit sound kit: a chime for a signal home, a soft double tap for a wrong one, a whoosh as static's binned.
|
||||
if (ev and ChaosEvents.MATCH != 0) audio.sfx(Sfx.MATCH, soundsOn)
|
||||
if (ev and ChaosEvents.WRONG != 0) audio.sfx(Sfx.NOPE, soundsOn)
|
||||
if (ev and ChaosEvents.BIN != 0) audio.sfx(Sfx.WHOOSH, soundsOn)
|
||||
if (ev and (ChaosEvents.MISSED or ChaosEvents.JAMMED) != 0 && ev and ChaosEvents.OVER == 0) audio.sfx(Sfx.PLAYER_HIT, soundsOn)
|
||||
if (ev and ChaosEvents.POWER != 0) audio.sfx(Sfx.POWER, soundsOn)
|
||||
if (ev and ChaosEvents.BONUS != 0) audio.sfx(Sfx.STAR, soundsOn)
|
||||
if (ev and ChaosEvents.REPAIRED != 0) audio.sfx(Sfx.SHIELD, soundsOn)
|
||||
if (ev and ChaosEvents.STAGE != 0) audio.sfx(Sfx.LEVEL_CLEAR, soundsOn)
|
||||
if (ev and ChaosEvents.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 = Stage.Result }
|
||||
|
||||
@@ -32,6 +32,7 @@ import tv.orbit.classic.arcade.Control
|
||||
import tv.orbit.classic.arcade.HowToPlayCard
|
||||
import tv.orbit.classic.arcade.KeyFooter
|
||||
import tv.orbit.classic.arcade.RunEnd
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import tv.orbit.classic.arcade.gameKeys
|
||||
|
||||
/** The on-screen keyboard: three rows of letters, then Delete and Try on the bottom row (each row fits teletext's 40 columns). */
|
||||
@@ -125,6 +126,7 @@ internal fun CodebreakerScreen(play: ArcadePlay) {
|
||||
var cr by remember { mutableIntStateOf(0) }; var cc by remember { mutableIntStateOf(0) }
|
||||
var version by remember { mutableIntStateOf(0) }
|
||||
val focus = remember { FocusRequester() }
|
||||
val soundsOn = remember { play.setting("sounds") }
|
||||
// Page 888, drawn into one small bitmap only when something on it changes.
|
||||
val page = remember { TeletextPage() }
|
||||
val pixels = remember { IntArray(Teletext.WIDTH * Teletext.HEIGHT) }
|
||||
@@ -174,15 +176,19 @@ internal fun CodebreakerScreen(play: ArcadePlay) {
|
||||
return@gameKeys true
|
||||
}
|
||||
when (key) {
|
||||
ArcadeKey.Left -> { val (r, c) = codeCursor(cr, cc, -1, 0); cr = r; cc = c }
|
||||
ArcadeKey.Right -> { val (r, c) = codeCursor(cr, cc, 1, 0); cr = r; cc = c }
|
||||
ArcadeKey.Up -> { val (r, c) = codeCursor(cr, cc, 0, -1); cr = r; cc = c }
|
||||
ArcadeKey.Down -> { val (r, c) = codeCursor(cr, cc, 0, 1); cr = r; cc = c }
|
||||
ArcadeKey.Left -> { val (r, c) = codeCursor(cr, cc, -1, 0); if (r != cr || c != cc) play.audio.sfx(Sfx.MOVE, soundsOn); cr = r; cc = c }
|
||||
ArcadeKey.Right -> { val (r, c) = codeCursor(cr, cc, 1, 0); if (r != cr || c != cc) play.audio.sfx(Sfx.MOVE, soundsOn); cr = r; cc = c }
|
||||
ArcadeKey.Up -> { val (r, c) = codeCursor(cr, cc, 0, -1); if (r != cr || c != cc) play.audio.sfx(Sfx.MOVE, soundsOn); cr = r; cc = c }
|
||||
ArcadeKey.Down -> { val (r, c) = codeCursor(cr, cc, 0, 1); if (r != cr || c != cc) play.audio.sfx(Sfx.MOVE, soundsOn); cr = r; cc = c }
|
||||
ArcadeKey.Ok -> if (native.repeatCount == 0) {
|
||||
// The Orbit sound kit: a key's tick, a soft tap for a try, a chime for the code cracked.
|
||||
when (val k = CodeKeys[cr][cc]) {
|
||||
"DEL" -> game.delete()
|
||||
"TRY" -> if (game.enter() && game.over) finish()
|
||||
else -> game.type(k[0])
|
||||
"DEL" -> play.audio.sfx(if (game.delete()) Sfx.BACK else Sfx.NOPE, soundsOn)
|
||||
"TRY" -> if (game.enter()) {
|
||||
play.audio.sfx(if (game.won) Sfx.LEVEL_CLEAR else if (game.lost) Sfx.GAME_OVER else Sfx.PLACE, soundsOn)
|
||||
if (game.over) finish()
|
||||
} else play.audio.sfx(Sfx.NOPE, soundsOn)
|
||||
else -> play.audio.sfx(if (game.type(k[0])) Sfx.TICK else Sfx.NOPE, soundsOn)
|
||||
}
|
||||
version++
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tv.orbit.classic.arcade.nightshift
|
||||
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import android.view.KeyEvent
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.Canvas
|
||||
@@ -109,6 +110,7 @@ internal fun NightShiftScreen(play: ArcadePlay) {
|
||||
var powerMenu by remember { mutableStateOf(false) }
|
||||
val par = nightPar(game.level, play.difficulty)
|
||||
val focus = remember { FocusRequester() }
|
||||
val soundsOn = remember { play.setting("sounds") }
|
||||
|
||||
fun startLevel(c: Int, l: Int) {
|
||||
chapter = c; levelIx = l; game = NightGame(NightChapters[c].levels[l]); paused = false; finished = null; stage = NightStage.Play
|
||||
@@ -117,6 +119,7 @@ internal fun NightShiftScreen(play: ArcadePlay) {
|
||||
fun use(p: NightPower) {
|
||||
if ((powers[p] ?: 0) <= 0) return
|
||||
powers = powers + (p to (powers[p] ?: 0) - 1)
|
||||
latestPlay.audio.sfx(Sfx.POWER, soundsOn)
|
||||
when (p) { NightPower.Moonbeam -> moonbeam = true; NightPower.SleepyTime -> game = game.sleepyTime(); NightPower.StarMagnet -> game = game.starMagnet(); NightPower.NightVision -> nightVision = true }
|
||||
powerMenu = false; paused = false
|
||||
}
|
||||
@@ -132,6 +135,7 @@ internal fun NightShiftScreen(play: ArcadePlay) {
|
||||
}
|
||||
latestPlay.onRunEnd(RunEnd(NightProgress.totalStars(saved), finished = true, detail = "Ch ${chapter + 1} · Level ${levelIx + 1}"))
|
||||
finished = Triple(stars, game.moves, par)
|
||||
latestPlay.audio.sfx(Sfx.LEVEL_CLEAR, soundsOn)
|
||||
stage = NightStage.Complete
|
||||
}
|
||||
LaunchedEffect(stage, paused) { if (stage == NightStage.Play && !paused) runCatching { focus.requestFocus() } }
|
||||
@@ -156,7 +160,14 @@ internal fun NightShiftScreen(play: ArcadePlay) {
|
||||
ArcadeKey.Ok -> if (native.repeatCount > 0) game else game.turn()
|
||||
else -> null
|
||||
}
|
||||
if (next != null) game = next
|
||||
if (next != null) {
|
||||
// The Orbit sound kit: a tick for a hop, a click for a turn, a soft bell when more of the beam lights up.
|
||||
if (key == ArcadeKey.Ok) {
|
||||
if (next === game) { if (native.repeatCount == 0) play.audio.sfx(Sfx.NOPE, soundsOn) }
|
||||
else { play.audio.sfx(Sfx.TURN, soundsOn); if (next.lit().count { it } > game.lit().count { it } && !next.won) play.audio.sfx(Sfx.LIGHT, soundsOn) }
|
||||
} else if (next !== game) play.audio.sfx(Sfx.MOVE, soundsOn)
|
||||
game = next
|
||||
}
|
||||
next != null
|
||||
}
|
||||
NightPlay(game, chapter, levelIx, par, keys, still = Motion.reduce || play.reduceFlashing, powers = powers, moonbeam = moonbeam, nightVision = nightVision)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tv.orbit.classic.arcade.orbiteroids
|
||||
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import android.view.KeyEvent
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.Canvas
|
||||
@@ -42,7 +43,6 @@ 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
|
||||
@@ -148,7 +148,6 @@ internal fun OrbiteroidsScreen(play: ArcadePlay) {
|
||||
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)
|
||||
@@ -163,8 +162,17 @@ internal fun OrbiteroidsScreen(play: ArcadePlay) {
|
||||
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)
|
||||
if (ev != 0) {
|
||||
// The Orbit sound kit. Zip fires a lot, so his pew sits a little under the rest.
|
||||
val audio = latestPlay.audio
|
||||
if (ev and OEvents.SHOT != 0) audio.sfx(Sfx.FIRE, soundsOn, .8f)
|
||||
if (ev and OEvents.CLEARED != 0) audio.sfx(Sfx.BREAK, soundsOn) else if (ev and OEvents.HIT != 0) audio.sfx(Sfx.HIT, soundsOn)
|
||||
if (ev and OEvents.HURT != 0 && ev and OEvents.OVER == 0) audio.sfx(Sfx.PLAYER_HIT, soundsOn)
|
||||
if (ev and OEvents.POWER != 0) audio.sfx(Sfx.POWER, soundsOn)
|
||||
if (ev and OEvents.DRIFT != 0) audio.sfx(Sfx.STAR, soundsOn)
|
||||
if (ev and OEvents.SECTOR != 0) audio.sfx(Sfx.LEVEL_CLEAR, soundsOn)
|
||||
if (ev and OEvents.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 = OStage.Result }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tv.orbit.classic.arcade.quiz
|
||||
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.background
|
||||
@@ -67,6 +68,7 @@ internal fun QuizNightScreen(play: ArcadePlay) {
|
||||
var tick by remember { mutableIntStateOf(0) } // the game is a plain object: this redraws it after each answer
|
||||
var bestBefore by remember { mutableIntStateOf(play.best) }
|
||||
val backdrop = ArcadeBackdrop.TestCardDusk
|
||||
val soundsOn = remember { play.setting("sounds") }
|
||||
|
||||
fun start() {
|
||||
latestPlay.setLevel("quiz.players", levels.joinToString(",") { it.name })
|
||||
@@ -76,6 +78,7 @@ internal fun QuizNightScreen(play: ArcadePlay) {
|
||||
}
|
||||
// A game on your own goes in the High Scores; a game for several is everyone's, so it keeps none.
|
||||
fun finish(g: QuizGame) {
|
||||
latestPlay.audio.sfx(if (g.players.size == 1 && g.scores[0] > bestBefore) Sfx.NEW_BEST else Sfx.LEVEL_CLEAR, soundsOn)
|
||||
if (g.players.size == 1) latestPlay.onRunEnd(RunEnd(g.scores[0], finished = true, detail = "${g.rights[0]} of ${g.rounds} · ${g.players[0].level.title}"))
|
||||
stage = QuizStage.Result
|
||||
}
|
||||
@@ -92,7 +95,7 @@ internal fun QuizNightScreen(play: ArcadePlay) {
|
||||
QuizStage.Players -> QuizPlayers(levels, quizLevels(play.kids), backdrop, onChange = { levels = it }, onStart = ::start, onBack = { stage = QuizStage.Title })
|
||||
QuizStage.Question -> game?.let { g ->
|
||||
tick // read, so each answer and each next question redraw
|
||||
QuizAskScreen(g, backdrop, paused, onAnswer = { g.answer(it); tick++ }, onNext = { g.next(); tick++; if (g.over) finish(g) }, onPause = { paused = true })
|
||||
QuizAskScreen(g, backdrop, paused, onAnswer = { latestPlay.audio.sfx(if (g.answer(it)) Sfx.MATCH else Sfx.NOPE, soundsOn); tick++ }, onNext = { g.next(); tick++; if (g.over) finish(g) }, onPause = { paused = true })
|
||||
if (paused) ArcadePauseMenu(gameDef, "Quiz Night · Round ${g.round} of ${g.rounds}", onResume = { paused = false }, onRestart = ::start, onExit = { latestPlay.onLeave() })
|
||||
}
|
||||
QuizStage.Result -> game?.let { g ->
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tv.orbit.classic.arcade.raiders
|
||||
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import android.view.KeyEvent
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.Canvas
|
||||
@@ -155,9 +156,18 @@ internal fun OrbiRaidersScreen(play: ArcadePlay) {
|
||||
val ev = sim.takeEvents()
|
||||
if (ev != 0) {
|
||||
val audio = latestPlay.audio
|
||||
if (ev and Events.POWER != 0) audio.cue(R.raw.power_drift_net, .6f, soundsOn)
|
||||
// The Orbit sound kit: a soft pew, a fade as an invader goes, a bonk when you're hit; the pilots' Overdrives keep their own sounds.
|
||||
if (ev and Events.SHOT != 0) audio.sfx(Sfx.FIRE, soundsOn)
|
||||
if (ev and Events.DAMAGED != 0) audio.sfx(Sfx.HIT, soundsOn)
|
||||
if (ev and Events.KILL != 0) audio.sfx(Sfx.FADE, soundsOn)
|
||||
if (ev and Events.BOSS_HIT != 0) audio.sfx(Sfx.BOSS_HIT, soundsOn)
|
||||
if (ev and Events.SHIELDED != 0) audio.sfx(Sfx.SHIELD, soundsOn)
|
||||
if (ev and Events.HIT != 0 && ev and Events.GAME_OVER == 0) audio.sfx(Sfx.PLAYER_HIT, soundsOn)
|
||||
if (ev and Events.POWER != 0) audio.sfx(Sfx.POWER, soundsOn)
|
||||
if (ev and Events.OVERDRIVE != 0) audio.cue(overdriveSound(sim.pilot), .7f, soundsOn)
|
||||
if (ev and Events.BOSS_DOWN != 0) audio.cue(R.raw.power_wide_orbit, .7f, soundsOn)
|
||||
if (ev and Events.BOSS_DOWN != 0) audio.sfx(Sfx.BOSS_DOWN, soundsOn)
|
||||
else if (ev and Events.WAVE_CLEAR != 0) audio.sfx(Sfx.LEVEL_CLEAR, soundsOn)
|
||||
if (ev and Events.GAME_OVER != 0) audio.sfx(if (sim.score > bestBefore) Sfx.NEW_BEST else Sfx.GAME_OVER, soundsOn)
|
||||
// Story: who's been met (Endless brings them back), and finishing it, saved to this profile at once.
|
||||
if (ev and Events.BOSS_MET != 0) latestPlay.setLevel(StorySave.MET, sim.metMask.toString())
|
||||
if (ev and Events.STORY_DONE != 0) latestPlay.setLevels(tv.orbit.classic.ArcadeProgress.storyCompleteValues(System.currentTimeMillis(), sim.difficulty))
|
||||
|
||||
@@ -198,6 +198,10 @@ internal object Events {
|
||||
const val BOSS_MET = 512
|
||||
/** Story finished: the wizard has said his piece. */
|
||||
const val STORY_DONE = 1024
|
||||
/** A boss takes a hit and carries on. */
|
||||
const val BOSS_HIT = 2048
|
||||
/** An invader takes a hit and carries on (a satellite, a tougher one). */
|
||||
const val DAMAGED = 4096
|
||||
}
|
||||
|
||||
/** Where a wave stands. */
|
||||
@@ -864,8 +868,8 @@ internal class RaidersSim(var pilot: Pilot = Pilot.Ollie, difficulty: Difficulty
|
||||
val e = enemies[i]
|
||||
e.hp -= dmg; e.tint = .12f
|
||||
damage += dmg
|
||||
if (e.kind == Kind.SATELLITE && e.hp > 0) { score += 5 * multiplier; return }
|
||||
if (e.hp > 0) return
|
||||
if (e.kind == Kind.SATELLITE && e.hp > 0) { score += 5 * multiplier; events = events or Events.DAMAGED; return }
|
||||
if (e.hp > 0) { events = events or Events.DAMAGED; return }
|
||||
kill(e)
|
||||
}
|
||||
|
||||
@@ -897,6 +901,7 @@ internal class RaidersSim(var pilot: Pilot = Pilot.Ollie, difficulty: Difficulty
|
||||
}
|
||||
score += 5 * multiplier
|
||||
meter = minOf(1f, meter + .006f * dmg)
|
||||
if (bossHp > 0) events = events or Events.BOSS_HIT
|
||||
if (bossHp <= 0) {
|
||||
bossOn = false; bossHp = 0; beamOn = 0f; bossWarn = 0f; swoop = 0f; indexVolleyIn = 0f
|
||||
score += 1500 * (wave / 5)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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
|
||||
@@ -30,7 +31,6 @@ 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.R
|
||||
import tv.orbit.classic.arcade.ArcadeColours
|
||||
import tv.orbit.classic.arcade.ArcadeGameLoop
|
||||
import tv.orbit.classic.arcade.ArcadeGames
|
||||
@@ -95,7 +95,6 @@ internal fun OrbitRushScreen(play: ArcadePlay) {
|
||||
val tracker = remember { RunTracker { end -> latestPlay.onRunEnd(end) } }
|
||||
fun endRun(finished: Boolean) { tracker.end(RunEnd(sim.score, finished, "${sim.distance.toInt()} m")) }
|
||||
DisposableEffect(Unit) { onDispose { endRun(false) } }
|
||||
LaunchedEffect(Unit) { play.audio.preload(R.raw.power_wide_orbit) }
|
||||
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 leave() { endRun(sim.over); latestPlay.onLeave() }
|
||||
@@ -104,7 +103,15 @@ internal fun OrbitRushScreen(play: ArcadePlay) {
|
||||
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 (REvents.POWER or REvents.SHIELD_ON) != 0) latestPlay.audio.cue(R.raw.power_wide_orbit, .6f, soundsOn)
|
||||
if (ev != 0) {
|
||||
// The Orbit sound kit: a ping for a star, a soft bonk for a knock, the shield's shimmer.
|
||||
val audio = latestPlay.audio
|
||||
if (ev and REvents.STAR != 0) audio.sfx(Sfx.STAR, 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.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 }
|
||||
}
|
||||
@@ -125,8 +132,11 @@ internal fun OrbitRushScreen(play: ArcadePlay) {
|
||||
val keys = Modifier.focusRequester(focus).focusable().gameKeys(enabled = stage == RStage.Play && !paused, pause = ::pause) { key, native ->
|
||||
if (native.action != KeyEvent.ACTION_DOWN) return@gameKeys key != ArcadeKey.Other
|
||||
when (key) {
|
||||
ArcadeKey.Left -> sim.left(); ArcadeKey.Right -> sim.right()
|
||||
ArcadeKey.Up -> if (native.repeatCount == 0) sim.rise(); ArcadeKey.Down -> if (native.repeatCount == 0) sim.dive()
|
||||
// A whoosh for a lane change that happens, a sweep up or down for a rise or dive.
|
||||
ArcadeKey.Left -> { val was = sim.lane; sim.left(); if (sim.lane != was) latestPlay.audio.sfx(Sfx.WHOOSH, soundsOn) }
|
||||
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()
|
||||
else -> return@gameKeys false
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import tv.orbit.classic.arcade.KeyFooter
|
||||
import tv.orbit.classic.arcade.RunEnd
|
||||
import tv.orbit.classic.arcade.SpeechBubble
|
||||
import tv.orbit.classic.arcade.classicPanel
|
||||
import tv.orbit.classic.arcade.Sfx
|
||||
import tv.orbit.classic.arcade.gameKeys
|
||||
import tv.orbit.classic.arcade.onBackKey
|
||||
import tv.orbit.classic.drawOrbChaser
|
||||
@@ -66,6 +67,7 @@ internal fun TestCardTangleScreen(play: ArcadePlay) {
|
||||
var game by remember { mutableStateOf(TangleGame(TangleLevels[TangleProgress.next(play.level) - 1])) }
|
||||
var finished by remember { mutableStateOf<Pair<Int, Int>?>(null) } // stars, moves
|
||||
val focus = remember { FocusRequester() }
|
||||
val soundsOn = remember { play.setting("sounds") }
|
||||
val backdrop = ArcadeBackdrop.TestCardDusk
|
||||
val par = tanglePar(game.level)
|
||||
|
||||
@@ -81,6 +83,7 @@ internal fun TestCardTangleScreen(play: ArcadePlay) {
|
||||
// The High Scores keep how many pictures are back on.
|
||||
latestPlay.onRunEnd(RunEnd(TangleProgress.cleared(saved), finished = true, detail = "Level ${game.level.number}"))
|
||||
finished = stars to game.moves
|
||||
latestPlay.audio.sfx(Sfx.LEVEL_CLEAR, soundsOn)
|
||||
stage = TStage.Done
|
||||
}
|
||||
LaunchedEffect(stage, paused) { if (stage == TStage.Play && !paused) runCatching { focus.requestFocus() } }
|
||||
@@ -105,7 +108,14 @@ internal fun TestCardTangleScreen(play: ArcadePlay) {
|
||||
ArcadeKey.Ok -> if (native.repeatCount > 0) game else game.turn()
|
||||
else -> null
|
||||
}
|
||||
if (next != null) game = next
|
||||
if (next != null) {
|
||||
// The Orbit sound kit: a tick as the cursor moves, a click for a turn, a soft bell when more cable joins the signal.
|
||||
if (key == ArcadeKey.Ok && next !== game) {
|
||||
play.audio.sfx(Sfx.TURN, soundsOn)
|
||||
if (next.lit().count { it } > lit.count { it } && !next.solved) play.audio.sfx(Sfx.LIGHT, soundsOn)
|
||||
} else if (next.cursor != game.cursor) play.audio.sfx(Sfx.MOVE, soundsOn)
|
||||
game = next
|
||||
}
|
||||
next != null
|
||||
}
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
|
||||
Reference in New Issue
Block a user