Orbit Arcade: Brick Break, and the honeycomb grows a row

A paddle, a ball and a wall of bricks for the remote (Paul's approved list):
hold left or right to move, OK to launch, Back to pause. Where the ball meets
the paddle sets its angle; two-hit bricks; four Orbit layouts that cycle,
each wall a little faster; three balls; best score kept on the box. The
arcade's honeycomb now holds Snake and OrbitHive over Block Drop and Brick
Break.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-05 17:35:48 +00:00
co-authored by Claude Opus 5.5
parent 99615f469d
commit 372ad4d416
4 changed files with 252 additions and 9 deletions
@@ -0,0 +1,46 @@
package tv.orbit.classic
import org.junit.Assert.*
import org.junit.Test
import kotlin.math.abs
/** Brick Break: the ball rides the paddle until launched, bounces off walls and paddle, breaks bricks, and costs a life when missed. */
class BrickBreakTest {
@Test fun theBallWaitsOnThePaddleUntilLaunched() {
val g = BrickGame.start().step(.5f, 1)
assertFalse(g.launched); assertEquals(g.paddleX, g.ballX, 0.01f)
assertTrue(g.paddleX > BRICK_W / 2)
val l = g.launch(); assertTrue(l.launched && l.vy < 0)
}
@Test fun thePaddleStopsAtTheEdges() {
assertTrue(BrickGame.start().step(5f, -1).paddleX >= 24f)
assertTrue(BrickGame.start().step(5f, 1).paddleX <= BRICK_W - 24f)
}
@Test fun aBrickBreaksAndTheBallTurnsBack() {
val one = Brick(4, 5, 1)
val g = BrickGame.start().copy(bricks = listOf(one, Brick(0, 0, 1)), launched = true, ballX = (one.left + one.right) / 2, ballY = one.bottom + 6, vx = 0f, vy = -160f)
val after = g.step(.1f, 0)
assertEquals(listOf(Brick(0, 0, 1)), after.bricks); assertEquals(10, after.score); assertTrue(after.vy > 0)
// A two-hit brick takes two.
val tough = Brick(4, 5, 2)
assertEquals(1, g.copy(bricks = listOf(tough, Brick(0, 0, 1))).step(.1f, 0).bricks.first { it.col == 4 }.hits)
}
@Test fun whereThePaddleIsHitSetsTheAngle() {
val g = BrickGame.start().copy(launched = true, bricks = listOf(Brick(0, 0, 1)), paddleX = 160f, ballY = 200f, vx = 0f, vy = 160f)
val middle = g.copy(ballX = 160f).step(.2f, 0); val edge = g.copy(ballX = 182f).step(.2f, 0)
assertTrue(middle.vy < 0 && edge.vy < 0)
assertTrue(abs(edge.vx) > abs(middle.vx))
}
@Test fun aMissedBallCostsALifeAndAClearedWallBringsTheNext() {
val missed = BrickGame.start().copy(launched = true, bricks = listOf(Brick(0, 0, 1)), paddleX = 30f, ballX = 300f, ballY = 230f, vx = 0f, vy = 160f).step(.3f, 0)
assertEquals(2, missed.lives); assertFalse(missed.launched)
val last = Brick(4, 5, 1)
val cleared = BrickGame.start().copy(bricks = listOf(last), launched = true, ballX = (last.left + last.right) / 2, ballY = last.bottom + 6, vx = 0f, vy = -160f).step(.1f, 0)
assertEquals(2, cleared.level); assertEquals(bricksFor(2), cleared.bricks); assertTrue(cleared.speed > BrickGame.start().speed)
assertFalse(BrickGame.start().copy(lives = 0).alive)
}
}