BlocksGame

class BlocksGame(val difficulty: BlocksDifficulty, random: Random = Random.Default)

Falling-block puzzle state. Pure logic: the screen calls tick on a timer and the move functions from gestures, then redraws. Cells hold 0 for empty or Tetromino.ordinal + 1.

Constructors

Link copied to clipboard
constructor(difficulty: BlocksDifficulty, random: Random = Random.Default)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Speeds up about 12% per level.

Link copied to clipboard
Link copied to clipboard
val height: Int
Link copied to clipboard

Rows cleared by the most recent lock, for the flash animation; clearCount changes each time.

Link copied to clipboard
val level: Int
Link copied to clipboard
var lines: Int
Link copied to clipboard

Bumped on every lock, so the UI can bounce the landing piece.

Link copied to clipboard
Link copied to clipboard

The stack topped out: the run is finished.

Link copied to clipboard
Link copied to clipboard
var px: Int
Link copied to clipboard
var py: Int
Link copied to clipboard
var rot: Int
Link copied to clipboard
var score: Int
Link copied to clipboard
val width: Int
Link copied to clipboard

The line milestone was passed at some point during this run.

Functions

Link copied to clipboard
fun cellsOf(type: Tetromino = piece, r: Int = rot, x: Int = px, y: Int = py): List<Pair<Int, Int>>
Link copied to clipboard
fun fits(type: Tetromino, r: Int, x: Int, y: Int): Boolean
Link copied to clipboard
operator fun get(x: Int, y: Int): Int
Link copied to clipboard
fun ghostY(): Int
Link copied to clipboard
fun hardDrop(): Int

Drops straight down and locks. Returns rows fallen.

Link copied to clipboard
fun move(dx: Int): Boolean
Link copied to clipboard

Rotates clockwise, nudging sideways or up if the plain rotation collides.

Link copied to clipboard

Everything needed to rebuild this run exactly — used to resume after the app is backgrounded.

Link copied to clipboard
Link copied to clipboard
fun tick()

Gravity step: fall one row or lock in place.